From: Lukasz Pawelczyk Date: Mon, 4 Sep 2017 13:06:03 +0000 (+0200) Subject: Fix a possible cached data save failure, sync just before reboot X-Git-Tag: submit/tizen/20170918.080130~8 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=aa72142da342eed256d95ace2f17ae7ae8e81452;p=platform%2Fcore%2Fsecurity%2Fode.git Fix a possible cached data save failure, sync just before reboot Change-Id: I6646e36cf600d260128f1d688aa2f74e1e5c6f5f --- diff --git a/server/internal-encryption.cpp b/server/internal-encryption.cpp index 023b9e0..cfb9099 100644 --- a/server/internal-encryption.cpp +++ b/server/internal-encryption.cpp @@ -335,12 +335,13 @@ int InternalEncryption::encrypt(const std::string& password, unsigned int option INFO(SINK, "Encryption started..."); engine->encrypt(MasterKey, options); setOptions(options & getSupportedOptions()); - INFO(SINK, "Sync disk..."); - sync(); - INFO(SINK, "Encryption completed"); + INFO(SINK, "Encryption completed"); ::vconf_set_str(INTERNAL_STATE_VCONF_KEY, "encrypted"); context.notify("InternalEncryption::mount"); + + INFO(SINK, "Syncing disk and rebooting..."); + ::sync(); ::reboot(RB_AUTOBOOT); } catch (runtime::Exception &e) { ::vconf_set_str(INTERNAL_STATE_VCONF_KEY, "error_partially_encrypted"); @@ -388,11 +389,12 @@ int InternalEncryption::decrypt(const std::string& password) INFO(SINK, "Decryption started..."); engine->decrypt(MasterKey, getOptions()); - INFO(SINK, "Sync disk..."); - sync(); - INFO(SINK, "Decryption completed"); + INFO(SINK, "Decryption completed"); ::vconf_set_str(INTERNAL_STATE_VCONF_KEY, "unencrypted"); + + INFO(SINK, "Syncing disk and rebooting..."); + ::sync(); ::reboot(RB_AUTOBOOT); } catch (runtime::Exception &e) { ::vconf_set_str(INTERNAL_STATE_VCONF_KEY, "error_partially_encrypted");