Skip to content

Commit

Permalink
Storage: do not create app folders in path resolving process in certa…
Browse files Browse the repository at this point in the history
…in cases.
  • Loading branch information
DrZlo13 committed Mar 1, 2023
1 parent dfd16b5 commit 9728587
Showing 1 changed file with 15 additions and 10 deletions.
25 changes: 15 additions & 10 deletions applications/services/storage/storage_processing.c
Original file line number Diff line number Diff line change
Expand Up @@ -445,7 +445,11 @@ static FS_Error storage_process_sd_status(Storage* app) {

/******************** Aliases processing *******************/

void storage_process_alias(Storage* app, FuriString* path, FuriThreadId thread_id) {
void storage_process_alias(
Storage* app,
FuriString* path,
FuriThreadId thread_id,
bool create_folders) {
if(furi_string_start_with(path, STORAGE_APP_DATA_PATH_PREFIX)) {
FuriString* apps_data_path_with_appsid = furi_string_alloc_set(APPS_DATA_PATH "/");
furi_string_cat(apps_data_path_with_appsid, furi_thread_get_appid(thread_id));
Expand All @@ -458,7 +462,8 @@ void storage_process_alias(Storage* app, FuriString* path, FuriThreadId thread_i
furi_string_get_cstr(apps_data_path_with_appsid));

// Create app data folder if not exists
if(storage_process_common_stat(app, apps_data_path_with_appsid, NULL) != FSE_OK) {
if(create_folders &&
storage_process_common_stat(app, apps_data_path_with_appsid, NULL) != FSE_OK) {
furi_string_set(apps_data_path_with_appsid, APPS_DATA_PATH);
storage_process_common_mkdir(app, apps_data_path_with_appsid);
furi_string_cat(apps_data_path_with_appsid, "/");
Expand All @@ -479,7 +484,7 @@ void storage_process_message_internal(Storage* app, StorageMessage* message) {
// File operations
case StorageCommandFileOpen:
path = furi_string_alloc_set(message->data->fopen.path);
storage_process_alias(app, path, message->data->fopen.thread_id);
storage_process_alias(app, path, message->data->fopen.thread_id, true);
message->return_data->bool_value = storage_process_file_open(
app,
message->data->fopen.file,
Expand Down Expand Up @@ -535,7 +540,7 @@ void storage_process_message_internal(Storage* app, StorageMessage* message) {
// Dir operations
case StorageCommandDirOpen:
path = furi_string_alloc_set(message->data->dopen.path);
storage_process_alias(app, path, message->data->dopen.thread_id);
storage_process_alias(app, path, message->data->dopen.thread_id, true);
message->return_data->bool_value =
storage_process_dir_open(app, message->data->dopen.file, path);
break;
Expand All @@ -559,35 +564,35 @@ void storage_process_message_internal(Storage* app, StorageMessage* message) {
// Common operations
case StorageCommandCommonTimestamp:
path = furi_string_alloc_set(message->data->ctimestamp.path);
storage_process_alias(app, path, message->data->ctimestamp.thread_id);
storage_process_alias(app, path, message->data->ctimestamp.thread_id, false);
message->return_data->error_value =
storage_process_common_timestamp(app, path, message->data->ctimestamp.timestamp);
break;
case StorageCommandCommonStat:
path = furi_string_alloc_set(message->data->cstat.path);
storage_process_alias(app, path, message->data->cstat.thread_id);
storage_process_alias(app, path, message->data->cstat.thread_id, false);
message->return_data->error_value =
storage_process_common_stat(app, path, message->data->cstat.fileinfo);
break;
case StorageCommandCommonRemove:
path = furi_string_alloc_set(message->data->path.path);
storage_process_alias(app, path, message->data->path.thread_id);
storage_process_alias(app, path, message->data->path.thread_id, false);
message->return_data->error_value = storage_process_common_remove(app, path);
break;
case StorageCommandCommonMkDir:
path = furi_string_alloc_set(message->data->path.path);
storage_process_alias(app, path, message->data->path.thread_id);
storage_process_alias(app, path, message->data->path.thread_id, true);
message->return_data->error_value = storage_process_common_mkdir(app, path);
break;
case StorageCommandCommonFSInfo:
path = furi_string_alloc_set(message->data->cfsinfo.fs_path);
storage_process_alias(app, path, message->data->cfsinfo.thread_id);
storage_process_alias(app, path, message->data->cfsinfo.thread_id, false);
message->return_data->error_value = storage_process_common_fs_info(
app, path, message->data->cfsinfo.total_space, message->data->cfsinfo.free_space);
break;
case StorageCommandCommonResolvePath:
storage_process_alias(
app, message->data->cresolvepath.path, message->data->cresolvepath.thread_id);
app, message->data->cresolvepath.path, message->data->cresolvepath.thread_id, true);
break;

// SD operations
Expand Down

0 comments on commit 9728587

Please sign in to comment.