[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:
Nikolay Minaylov 2022-04-14 20:02:16 +03:00 committed by GitHub
parent c97d9a633e
commit e67cdbdff8
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 9 additions and 2 deletions

View File

@ -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;
});
}

View File

@ -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");