diff --git a/applications/main/archive/helpers/archive_files.c b/applications/main/archive/helpers/archive_files.c index df62030c8..e839fc772 100644 --- a/applications/main/archive/helpers/archive_files.c +++ b/applications/main/archive/helpers/archive_files.c @@ -135,11 +135,9 @@ FS_Error archive_copy_rename_file_or_dir( bool copy, bool find_name) { furi_assert(context); - const char* dst_cstr = furi_string_get_cstr(dst_path); + FURI_LOG_I( + TAG, "%s from %s to %s", copy ? "Copy" : "Move", src_path, furi_string_get_cstr(dst_path)); - FURI_LOG_I(TAG, "%s from %s to %s", copy ? "Copy" : "Move", src_path, dst_cstr); - - UNUSED(context); Storage* fs_api = furi_record_open(RECORD_STORAGE); FileInfo fileinfo; @@ -147,17 +145,17 @@ FS_Error archive_copy_rename_file_or_dir( FS_Error error = FSE_OK; - if(!path_contains_only_ascii(dst_cstr)) { + if(!path_contains_only_ascii(furi_string_get_cstr(dst_path))) { error = FSE_INVALID_NAME; - } else if(!copy && !strcmp(src_path, dst_cstr)) { + } else if(!copy && !strcmp(src_path, furi_string_get_cstr(dst_path))) { error = FSE_EXIST; } else { - if(find_name && storage_common_exists(fs_api, dst_cstr)) { + if(find_name && storage_common_exists(fs_api, furi_string_get_cstr(dst_path))) { FuriString* dir_path = furi_string_alloc(); FuriString* filename = furi_string_alloc(); FuriString* file_ext = furi_string_alloc(); - path_extract_dirname(dst_cstr, dir_path); + path_extract_dirname(furi_string_get_cstr(dst_path), dir_path); path_extract_filename(dst_path, filename, true); path_extract_ext_str(dst_path, file_ext); @@ -168,7 +166,8 @@ FS_Error archive_copy_rename_file_or_dir( furi_string_get_cstr(file_ext), dst_path, 255); - furi_string_cat_printf(dir_path, "/%s%s", dst_cstr, furi_string_get_cstr(file_ext)); + furi_string_cat_printf( + dir_path, "/%s%s", furi_string_get_cstr(dst_path), furi_string_get_cstr(file_ext)); furi_string_set(dst_path, dir_path); furi_string_free(dir_path); @@ -177,24 +176,31 @@ FS_Error archive_copy_rename_file_or_dir( } if(copy) { - error = storage_common_copy(fs_api, src_path, dst_cstr); + error = storage_common_copy(fs_api, src_path, furi_string_get_cstr(dst_path)); } else { - error = storage_common_rename(fs_api, src_path, dst_cstr); + error = storage_common_rename(fs_api, src_path, furi_string_get_cstr(dst_path)); } } furi_record_close(RECORD_STORAGE); if(!copy && archive_is_favorite("%s", src_path)) { - archive_favorites_rename(src_path, dst_cstr); + archive_favorites_rename(src_path, furi_string_get_cstr(dst_path)); } if(error == FSE_OK) { - FURI_LOG_I(TAG, "%s from %s to %s is DONE", copy ? "Copy" : "Move", src_path, dst_cstr); + FURI_LOG_I( + TAG, + "%s from %s to %s is DONE", + copy ? "Copy" : "Move", + src_path, + furi_string_get_cstr(dst_path)); } else { FURI_LOG_E( TAG, - "%s failed: %s, Code: %d", + "%s from %s to %s failed: %s, Code: %d", copy ? "Copy" : "Move", + src_path, + furi_string_get_cstr(dst_path), filesystem_api_error_get_desc(error), error); } diff --git a/applications/services/storage/storage_processing.c b/applications/services/storage/storage_processing.c index d1c2ba73a..aa0c3eac1 100644 --- a/applications/services/storage/storage_processing.c +++ b/applications/services/storage/storage_processing.c @@ -757,6 +757,10 @@ void storage_process_message_internal(Storage* app, StorageMessage* message) { storage_path_trim_trailing_slashes(path2); storage_process_alias(app, path1, message->data->cequivpath.thread_id, false); storage_process_alias(app, path2, message->data->cequivpath.thread_id, false); + // Comparison is done on path name, same beginning of name != same file/folder + // Check with a / suffixed to ensure same file/folder name + furi_string_cat(path1, "/"); + furi_string_cat(path2, "/"); if(message->data->cequivpath.truncate) { furi_string_left(path2, furi_string_size(path1)); }