Fix a possible cached data save failure, sync just before reboot 99/147499/4
authorLukasz Pawelczyk <l.pawelczyk@samsung.com>
Mon, 4 Sep 2017 13:06:03 +0000 (15:06 +0200)
committerLukasz Pawelczyk <l.pawelczyk@samsung.com>
Mon, 11 Sep 2017 11:26:20 +0000 (13:26 +0200)
Change-Id: I6646e36cf600d260128f1d688aa2f74e1e5c6f5f

server/internal-encryption.cpp

index 023b9e0..cfb9099 100644 (file)
@@ -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");