Split app move into separate copy/delete steps.
App movement now has three distinct stages: copying, scanning, and
cleanup. Previously, a battery pull late in the move process would
end up with packages.xml pointing at the old location which had been
torn down. Now, we update packages.xml to point at the new location
as the "source of truth" before we start deleting the old location.
Bug: 21831336
Change-Id: I62b8916c673265c240e2574ea968cdce5a7a0074
diff --git a/cmds/installd/commands.cpp b/cmds/installd/commands.cpp
index f2c76d5..0c3ae02 100644
--- a/cmds/installd/commands.cpp
+++ b/cmds/installd/commands.cpp
@@ -177,7 +177,7 @@
return 0;
}
-int move_complete_app(const char *from_uuid, const char *to_uuid,
+int copy_complete_app(const char *from_uuid, const char *to_uuid,
const char *package_name, const char *data_app_name, appid_t appid,
const char* seinfo) {
std::vector<userid_t> users = get_known_users(from_uuid);
@@ -264,19 +264,9 @@
}
}
- // Delete old app and data
- {
- std::string from(create_data_app_package_path(from_uuid, data_app_name));
- if (delete_dir_contents(from.c_str(), 1, NULL) != 0) {
- LOG(WARNING) << "Failed to delete " << from;
- }
- }
- for (auto user : users) {
- std::string from(create_data_user_package_path(from_uuid, user, package_name));
- if (delete_dir_contents(from.c_str(), 1, NULL) != 0) {
- LOG(WARNING) << "Failed to delete " << from;
- }
- }
+ // We let the framework scan the new location and persist that before
+ // deleting the data in the old location; this ordering ensures that
+ // we can recover from things like battery pulls.
return 0;
fail: