Merge "Split app move into separate copy/delete steps." into mnc-dev

This commit is contained in:
Jeff Sharkey 2015-07-07 20:46:32 +00:00 committed by Android (Google) Code Review
commit 570052f777
3 changed files with 8 additions and 18 deletions

View File

@ -177,7 +177,7 @@ int make_user_data(const char *uuid, const char *pkgname, uid_t uid, userid_t us
return 0; 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 *package_name, const char *data_app_name, appid_t appid,
const char* seinfo) { const char* seinfo) {
std::vector<userid_t> users = get_known_users(from_uuid); std::vector<userid_t> users = get_known_users(from_uuid);
@ -264,19 +264,9 @@ int move_complete_app(const char *from_uuid, const char *to_uuid,
} }
} }
// Delete old app and data // We let the framework scan the new location and persist that before
{ // deleting the data in the old location; this ordering ensures that
std::string from(create_data_app_package_path(from_uuid, data_app_name)); // we can recover from things like battery pulls.
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;
}
}
return 0; return 0;
fail: fail:

View File

@ -124,10 +124,10 @@ static int do_rm_user_data(char **arg, char reply[REPLY_MAX] __unused)
return delete_user_data(parse_null(arg[0]), arg[1], atoi(arg[2])); /* uuid, pkgname, userid */ return delete_user_data(parse_null(arg[0]), arg[1], atoi(arg[2])); /* uuid, pkgname, userid */
} }
static int do_mv_complete_app(char **arg, char reply[REPLY_MAX] __unused) static int do_cp_complete_app(char **arg, char reply[REPLY_MAX] __unused)
{ {
// from_uuid, to_uuid, package_name, data_app_name, appid, seinfo // from_uuid, to_uuid, package_name, data_app_name, appid, seinfo
return move_complete_app(parse_null(arg[0]), parse_null(arg[1]), arg[2], arg[3], atoi(arg[4]), arg[5]); return copy_complete_app(parse_null(arg[0]), parse_null(arg[1]), arg[2], arg[3], atoi(arg[4]), arg[5]);
} }
static int do_mk_user_data(char **arg, char reply[REPLY_MAX] __unused) static int do_mk_user_data(char **arg, char reply[REPLY_MAX] __unused)
@ -206,7 +206,7 @@ struct cmdinfo cmds[] = {
{ "rmcodecache", 3, do_rm_code_cache }, { "rmcodecache", 3, do_rm_code_cache },
{ "getsize", 8, do_get_size }, { "getsize", 8, do_get_size },
{ "rmuserdata", 3, do_rm_user_data }, { "rmuserdata", 3, do_rm_user_data },
{ "mvcompleteapp", 6, do_mv_complete_app }, { "cpcompleteapp", 6, do_cp_complete_app },
{ "movefiles", 0, do_movefiles }, { "movefiles", 0, do_movefiles },
{ "linklib", 4, do_linklib }, { "linklib", 4, do_linklib },
{ "mkuserdata", 5, do_mk_user_data }, { "mkuserdata", 5, do_mk_user_data },

View File

@ -225,7 +225,7 @@ int fix_uid(const char *uuid, const char *pkgname, uid_t uid, gid_t gid);
int delete_user_data(const char *uuid, const char *pkgname, userid_t userid); int delete_user_data(const char *uuid, const char *pkgname, userid_t userid);
int make_user_data(const char *uuid, const char *pkgname, uid_t uid, int make_user_data(const char *uuid, const char *pkgname, uid_t uid,
userid_t userid, const char* seinfo); userid_t userid, const char* seinfo);
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 *package_name, const char *data_app_name, appid_t appid,
const char* seinfo); const char* seinfo);
int make_user_config(userid_t userid); int make_user_config(userid_t userid);