[FL-2433] Archive: Fix favourites rescan (#1112)
* Archive: fix favourites rescan * Archive: fix favourites move Co-authored-by: あく <alleteam@gmail.com>
This commit is contained in:
parent
c97d9a633e
commit
e67cdbdff8
@ -120,13 +120,12 @@ void archive_file_array_swap(ArchiveBrowserView* browser, int8_t dir) {
|
||||
ArchiveFile_t_clear(&temp);
|
||||
} else if(model->item_idx == array_size && dir > 0) {
|
||||
ArchiveFile_t_init(&temp);
|
||||
files_array_pop_at(&temp, model->files, model->item_idx);
|
||||
files_array_pop_at(&temp, model->files, 0);
|
||||
files_array_push_at(model->files, array_size, temp);
|
||||
ArchiveFile_t_clear(&temp);
|
||||
} else {
|
||||
files_array_swap_at(model->files, model->item_idx, swap_idx);
|
||||
}
|
||||
|
||||
return false;
|
||||
});
|
||||
}
|
||||
|
@ -106,6 +106,8 @@ static bool archive_favourites_rescan() {
|
||||
if(file_exists) {
|
||||
storage_file_close(fav_item_file);
|
||||
archive_file_append(ARCHIVE_FAV_TEMP_PATH, "%s\n", string_get_cstr(buffer));
|
||||
} else {
|
||||
storage_file_close(fav_item_file);
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -116,6 +118,7 @@ static bool archive_favourites_rescan() {
|
||||
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_file_free(file);
|
||||
storage_file_free(fav_item_file);
|
||||
@ -163,10 +166,12 @@ bool archive_favorites_read(void* context) {
|
||||
bool file_exists = storage_file_open(
|
||||
fav_item_file, string_get_cstr(buffer), FSAM_READ, FSOM_OPEN_EXISTING);
|
||||
if(file_exists) {
|
||||
storage_common_stat(fs_api, string_get_cstr(buffer), &file_info);
|
||||
storage_file_close(fav_item_file);
|
||||
archive_add_file_item(browser, &file_info, string_get_cstr(buffer));
|
||||
file_count++;
|
||||
} else {
|
||||
storage_file_close(fav_item_file);
|
||||
need_refresh = true;
|
||||
}
|
||||
}
|
||||
@ -224,6 +229,7 @@ bool archive_favorites_delete(const char* format, ...) {
|
||||
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_file_free(file);
|
||||
furi_record_close("storage");
|
||||
@ -308,6 +314,7 @@ bool archive_favorites_rename(const char* src, const char* dst) {
|
||||
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_file_free(file);
|
||||
furi_record_close("storage");
|
||||
@ -335,6 +342,7 @@ void archive_favorites_save(void* context) {
|
||||
|
||||
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("storage");
|
||||
|
Loading…
Reference in New Issue
Block a user