[FL-2510] Fixed BT startup while backing up LFS (#1180)
* Waiting for dummy BT record on LFS ops; cleaner retry for backup file open * Fixed files not being closed on failed open
This commit is contained in:
@@ -206,12 +206,14 @@ static int archive_extract_foreach_cb(mtar_t* tar, const mtar_header_t* header,
|
||||
bool failed = false;
|
||||
uint8_t n_tries = FILE_OPEN_NTRIES;
|
||||
do {
|
||||
while(
|
||||
(n_tries-- > 0) &&
|
||||
!storage_file_open(out_file, string_get_cstr(fname), FSAM_WRITE, FSOM_CREATE_ALWAYS)) {
|
||||
while(n_tries-- > 0) {
|
||||
if(storage_file_open(
|
||||
out_file, string_get_cstr(fname), FSAM_WRITE, FSOM_CREATE_ALWAYS)) {
|
||||
break;
|
||||
}
|
||||
FURI_LOG_W(TAG, "Failed to open '%s', reties: %d", string_get_cstr(fname), n_tries);
|
||||
storage_file_close(out_file);
|
||||
osDelay(FILE_OPEN_RETRY_DELAY);
|
||||
continue;
|
||||
}
|
||||
|
||||
if(!storage_file_is_open(out_file)) {
|
||||
@@ -257,11 +259,13 @@ bool tar_archive_add_file(
|
||||
File* src_file = storage_file_alloc(archive->storage);
|
||||
uint8_t n_tries = FILE_OPEN_NTRIES;
|
||||
do {
|
||||
while((n_tries-- > 0) &&
|
||||
!storage_file_open(src_file, fs_file_path, FSAM_READ, FSOM_OPEN_EXISTING)) {
|
||||
while(n_tries-- > 0) {
|
||||
if(storage_file_open(src_file, fs_file_path, FSAM_READ, FSOM_OPEN_EXISTING)) {
|
||||
break;
|
||||
}
|
||||
FURI_LOG_W(TAG, "Failed to open '%s', reties: %d", fs_file_path, n_tries);
|
||||
storage_file_close(src_file);
|
||||
osDelay(FILE_OPEN_RETRY_DELAY);
|
||||
continue;
|
||||
}
|
||||
|
||||
if(!storage_file_is_open(src_file) ||
|
||||
@@ -341,4 +345,4 @@ bool tar_archive_add_dir(TarArchive* archive, const char* fs_full_path, const ch
|
||||
free(name);
|
||||
storage_file_free(directory);
|
||||
return success;
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user