mirror of
https://github.com/Next-Flip/Momentum-Firmware.git
synced 2026-05-11 06:09:08 -07:00
Fix rename/move API, now rename/rename_safe (#468)
On OFW "rename" acts like "move", it replaces the destination XFW had an extra "move" like that, and "rename" errored if dest exists Now for compatibility "rename" acts as OFW, and new "rename_safe" errors Tweaked all usages to work properly Decided for CLI and RPC to use "rename_safe" so user cant lose files
This commit is contained in:
@@ -104,9 +104,9 @@ static bool archive_favourites_rescan() {
|
||||
furi_string_free(buffer);
|
||||
|
||||
storage_file_close(file);
|
||||
if(storage_common_move(storage, ARCHIVE_FAV_TEMP_PATH, ARCHIVE_FAV_PATH) == FSE_NOT_EXIST) {
|
||||
storage_common_remove(storage, ARCHIVE_FAV_PATH);
|
||||
}
|
||||
storage_common_remove(storage, ARCHIVE_FAV_PATH);
|
||||
storage_common_rename(storage, ARCHIVE_FAV_TEMP_PATH, ARCHIVE_FAV_PATH);
|
||||
storage_common_remove(storage, ARCHIVE_FAV_TEMP_PATH);
|
||||
|
||||
storage_file_free(file);
|
||||
furi_record_close(RECORD_STORAGE);
|
||||
@@ -203,9 +203,9 @@ bool archive_favorites_delete(const char* format, ...) {
|
||||
furi_string_free(filename);
|
||||
|
||||
storage_file_close(file);
|
||||
if(storage_common_move(fs_api, ARCHIVE_FAV_TEMP_PATH, ARCHIVE_FAV_PATH) == FSE_NOT_EXIST) {
|
||||
storage_common_remove(fs_api, ARCHIVE_FAV_PATH);
|
||||
}
|
||||
storage_common_remove(fs_api, ARCHIVE_FAV_PATH);
|
||||
storage_common_rename(fs_api, ARCHIVE_FAV_TEMP_PATH, ARCHIVE_FAV_PATH);
|
||||
storage_common_remove(fs_api, ARCHIVE_FAV_TEMP_PATH);
|
||||
|
||||
storage_file_free(file);
|
||||
furi_record_close(RECORD_STORAGE);
|
||||
@@ -282,9 +282,9 @@ bool archive_favorites_rename(const char* src, const char* dst) {
|
||||
furi_string_free(path);
|
||||
|
||||
storage_file_close(file);
|
||||
if(storage_common_move(fs_api, ARCHIVE_FAV_TEMP_PATH, ARCHIVE_FAV_PATH) == FSE_NOT_EXIST) {
|
||||
storage_common_remove(fs_api, ARCHIVE_FAV_PATH);
|
||||
}
|
||||
storage_common_remove(fs_api, ARCHIVE_FAV_PATH);
|
||||
storage_common_rename(fs_api, ARCHIVE_FAV_TEMP_PATH, ARCHIVE_FAV_PATH);
|
||||
storage_common_remove(fs_api, ARCHIVE_FAV_TEMP_PATH);
|
||||
|
||||
storage_file_free(file);
|
||||
furi_record_close(RECORD_STORAGE);
|
||||
@@ -310,9 +310,9 @@ void archive_favorites_save(void* context) {
|
||||
archive_file_append(ARCHIVE_FAV_TEMP_PATH, "%s\n", furi_string_get_cstr(item->path));
|
||||
}
|
||||
|
||||
if(storage_common_move(fs_api, ARCHIVE_FAV_TEMP_PATH, ARCHIVE_FAV_PATH) == FSE_NOT_EXIST) {
|
||||
storage_common_remove(fs_api, ARCHIVE_FAV_PATH);
|
||||
}
|
||||
storage_common_remove(fs_api, ARCHIVE_FAV_PATH);
|
||||
storage_common_rename(fs_api, ARCHIVE_FAV_TEMP_PATH, ARCHIVE_FAV_PATH);
|
||||
storage_common_remove(fs_api, ARCHIVE_FAV_TEMP_PATH);
|
||||
|
||||
storage_file_free(file);
|
||||
furi_record_close(RECORD_STORAGE);
|
||||
|
||||
@@ -178,7 +178,7 @@ FS_Error archive_copy_rename_file_or_dir(
|
||||
if(copy) {
|
||||
error = storage_common_copy(fs_api, src_path, furi_string_get_cstr(dst_path));
|
||||
} else {
|
||||
error = storage_common_rename(fs_api, src_path, furi_string_get_cstr(dst_path));
|
||||
error = storage_common_rename_safe(fs_api, src_path, furi_string_get_cstr(dst_path));
|
||||
}
|
||||
}
|
||||
furi_record_close(RECORD_STORAGE);
|
||||
|
||||
@@ -120,7 +120,7 @@ BadKbApp* bad_kb_app_alloc(char* arg) {
|
||||
}
|
||||
|
||||
Storage* storage = furi_record_open(RECORD_STORAGE);
|
||||
storage_common_rename(storage, EXT_PATH("badusb"), BAD_KB_APP_BASE_FOLDER);
|
||||
storage_common_rename_safe(storage, EXT_PATH("badusb"), BAD_KB_APP_BASE_FOLDER);
|
||||
storage_simply_mkdir(storage, BAD_KB_APP_BASE_FOLDER);
|
||||
furi_record_close(RECORD_STORAGE);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user