#include "tpk/external_dirs.h"
-#include <common/pkgdir_tool_request.h>
#include <common/privileges.h>
#include <common/pkgmgr_query.h>
#include <common/shared_dirs.h>
switch (request_mode) {
case ci::RequestMode::GLOBAL: {
LOG(DEBUG) << "Creating external directories for all users";
- ci::RequestCreateExternalDirectories(pkgid);
- break;
+ return ci::PerformExternalDirectoryCreationForAllUsers(pkgid);
}
case ci::RequestMode::USER: {
LOG(DEBUG) << "Creating external directories for user: " << uid;
- ci::PerformExternalDirectoryCreationForUser(uid, pkgid);
- break;
+ return ci::PerformExternalDirectoryCreationForUser(uid, pkgid);
+ }
+ default: {
+ LOG(ERROR) << "UNexpected request mode";
+ return false;
}
}
- return true;
}
bool DeleteExternalAppdataDirectories(const std::string& pkgid,
switch (request_mode) {
case ci::RequestMode::GLOBAL: {
LOG(DEBUG) << "Removing external directories for all users";
- ci::RequestDeleteExternalDirectories(pkgid);
- break;
+ return ci::PerformExternalDirectoryDeletionForAllUsers(pkgid);
}
case ci::RequestMode::USER: {
// if package is globally installed, leave directories
return true;
LOG(DEBUG) << "Removing external directories for user: " << uid;
- ci::PerformExternalDirectoryDeletionForUser(uid, pkgid);
- break;
+ return ci::PerformExternalDirectoryDeletionForUser(uid, pkgid);
+ }
+ default: {
+ LOG(ERROR) << "Unexpected request mode";
+ return false;
}
}
- return true;
}
} // namespace tpk
if (!HasExternalAppdataPrivilege(context_->manifest_data.get())) {
LOG(DEBUG) << "External storage privilege not found, skipping.";
return Status::OK;
- } else {
- if (!CreateExternalAppdataDirectories(context_->pkgid.get(),
- context_->request_mode.get(),
- context_->uid.get()))
- return Status::APP_DIR_ERROR;
+ }
+
+ if (!CreateExternalAppdataDirectories(context_->pkgid.get(),
+ context_->request_mode.get(),
+ context_->uid.get())) {
+ LOG(ERROR) << "Failed to create external appdata directories";
+ return Status::APP_DIR_ERROR;
}
return Status::OK;
}