Only write and encrypt the flat buffer when modified.

This commit is contained in:
Michael Lotz
2013-03-05 11:04:16 -05:00
committed by Ryan Leavengood
parent 1b3bb46aed
commit 6ef5917d45
2 changed files with 18 additions and 3 deletions
+17 -3
View File
@@ -10,7 +10,8 @@
Keyring::Keyring(const char* name, const BMessage* keyMessage) Keyring::Keyring(const char* name, const BMessage* keyMessage)
: :
fName(name), fName(name),
fAccessible(false) fAccessible(false),
fModified(false)
{ {
if (keyMessage != NULL) if (keyMessage != NULL)
Access(*keyMessage); Access(*keyMessage);
@@ -225,7 +226,12 @@ Keyring::AddKey(const BString& identifier, const BString& secondaryIdentifier,
return B_NAME_IN_USE; return B_NAME_IN_USE;
// We're fine, just add the new key. // We're fine, just add the new key.
return fData.AddMessage(identifier, &keyMessage); status_t result = fData.AddMessage(identifier, &keyMessage);
if (result != B_OK)
return result;
fModified = true;
return B_OK;
} }
@@ -250,7 +256,11 @@ Keyring::RemoveKey(const BString& identifier,
if (!candidate.HasSameData(keyMessage)) if (!candidate.HasSameData(keyMessage))
continue; continue;
fData.RemoveData(identifier, i); status_t result = fData.RemoveData(identifier, i);
if (result != B_OK)
return result;
fModified = true;
return B_OK; return B_OK;
} }
@@ -275,6 +285,9 @@ Keyring::Compare(const BString* name, const Keyring* keyring)
status_t status_t
Keyring::_EncryptToFlatBuffer() Keyring::_EncryptToFlatBuffer()
{ {
if (!fModified)
return B_OK;
if (!fAccessible) if (!fAccessible)
return B_NOT_ALLOWED; return B_NOT_ALLOWED;
@@ -296,6 +309,7 @@ Keyring::_EncryptToFlatBuffer()
// TODO: Actually encrypt the flat buffer... // TODO: Actually encrypt the flat buffer...
fModified = false;
return B_OK; return B_OK;
} }
+1
View File
@@ -54,6 +54,7 @@ private:
BMessage fApplications; BMessage fApplications;
BMessage fKeyMessage; BMessage fKeyMessage;
bool fAccessible; bool fAccessible;
bool fModified;
}; };