Use rename or move where appropriate

This commit is contained in:
Willy-JL
2023-05-26 22:21:32 +01:00
parent 8e6e5e18f0
commit 92f54c45ff
6 changed files with 9 additions and 18 deletions
@@ -112,9 +112,7 @@ static bool archive_favourites_rescan() {
furi_string_free(buffer);
storage_file_close(file);
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_common_move(storage, ARCHIVE_FAV_TEMP_PATH, ARCHIVE_FAV_PATH);
storage_file_free(file);
furi_record_close(RECORD_STORAGE);
@@ -217,9 +215,7 @@ bool archive_favorites_delete(const char* format, ...) {
furi_string_free(filename);
storage_file_close(file);
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_common_move(fs_api, ARCHIVE_FAV_TEMP_PATH, ARCHIVE_FAV_PATH);
storage_file_free(file);
furi_record_close(RECORD_STORAGE);
@@ -302,9 +298,7 @@ bool archive_favorites_rename(const char* src, const char* dst) {
furi_string_free(path);
storage_file_close(file);
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_common_move(fs_api, ARCHIVE_FAV_TEMP_PATH, ARCHIVE_FAV_PATH);
storage_file_free(file);
furi_record_close(RECORD_STORAGE);
@@ -330,9 +324,7 @@ void archive_favorites_save(void* context) {
archive_file_append(ARCHIVE_FAV_TEMP_PATH, "%s\n", furi_string_get_cstr(item->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_common_move(fs_api, ARCHIVE_FAV_TEMP_PATH, ARCHIVE_FAV_PATH);
storage_file_free(file);
furi_record_close(RECORD_STORAGE);
@@ -115,7 +115,7 @@ void archive_delete_file(void* context, const char* format, ...) {
furi_string_free(filename);
}
FS_Error archive_copy_move_file_or_dir(
FS_Error archive_copy_rename_file_or_dir(
void* context,
const char* src_path,
const char* dst_path,
@@ -117,7 +117,7 @@ void archive_file_append(const char* path, const char* format, ...)
_ATTRIBUTE((__format__(__printf__, 2, 3)));
void archive_delete_file(void* context, const char* format, ...)
_ATTRIBUTE((__format__(__printf__, 2, 3)));
FS_Error archive_copy_move_file_or_dir(
FS_Error archive_copy_rename_file_or_dir(
void* context,
const char* src_path,
const char* dst_path,
@@ -220,7 +220,7 @@ bool archive_scene_browser_on_event(void* context, SceneManagerEvent event) {
if(path_src && path_dst) {
view_dispatcher_switch_to_view(archive->view_dispatcher, ArchiveViewStack);
archive_show_loading_popup(archive, true);
FS_Error error = archive_copy_move_file_or_dir(
FS_Error error = archive_copy_rename_file_or_dir(
archive->browser,
furi_string_get_cstr(path_src),
furi_string_get_cstr(path_dst),
@@ -85,7 +85,7 @@ bool archive_scene_rename_on_event(void* context, SceneManagerEvent event) {
// Long time process if this is directory
view_dispatcher_switch_to_view(archive->view_dispatcher, ArchiveViewStack);
archive_show_loading_popup(archive, true);
FS_Error error = archive_copy_move_file_or_dir(
FS_Error error = archive_copy_rename_file_or_dir(
archive->browser, path_src, furi_string_get_cstr(path_dst), false, false);
archive_show_loading_popup(archive, false);
+1 -2
View File
@@ -66,8 +66,7 @@ void flipper_migrate_files() {
FileInfo file_info;
if(storage_common_stat(storage, U2F_CNT_OLD_FILE, &file_info) == FSE_OK &&
file_info.size > 200) { // Is on Int and has content
storage_common_remove(storage, U2F_CNT_FILE); // Remove outdated on Ext
storage_common_rename(storage, U2F_CNT_OLD_FILE, U2F_CNT_FILE); // Int -> Ext
storage_common_move(storage, U2F_CNT_OLD_FILE, U2F_CNT_FILE); // Int -> Ext
}
storage_common_copy(storage, U2F_KEY_OLD_FILE, U2F_KEY_FILE); // Ext -> Int