From cc61a25cd17f8662f56672e4d19f0a43579057f3 Mon Sep 17 00:00:00 2001 From: cyan Date: Fri, 4 Oct 2024 23:53:55 +0200 Subject: [PATCH] Set flush: true in backup service (#1717) This should ensure that files are flushed to disk before this function returns. Also, replaced foreach loop with for loop. --- lib/core/backup_service.dart | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/lib/core/backup_service.dart b/lib/core/backup_service.dart index 26e2136dc..ba90a0449 100644 --- a/lib/core/backup_service.dart +++ b/lib/core/backup_service.dart @@ -130,18 +130,18 @@ class BackupService { final decryptedData = await _decryptV1(data, password, nonce); final zip = ZipDecoder().decodeBytes(decryptedData); - zip.files.forEach((file) { + for (var file in zip.files) { final filename = file.name; if (file.isFile) { final content = file.content as List; File('${appDir.path}/' + filename) ..createSync(recursive: true) - ..writeAsBytesSync(content); + ..writeAsBytesSync(content, flush: true); } else { Directory('${appDir.path}/' + filename)..create(recursive: true); } - }); + }; await _verifyWallets(); await _importKeychainDumpV1(password, nonce: nonce); @@ -153,18 +153,18 @@ class BackupService { final decryptedData = await _decryptV2(data, password); final zip = ZipDecoder().decodeBytes(decryptedData); - zip.files.forEach((file) { + for (var file in zip.files) { final filename = file.name; if (file.isFile) { final content = file.content as List; File('${appDir.path}/' + filename) ..createSync(recursive: true) - ..writeAsBytesSync(content); + ..writeAsBytesSync(content, flush: true); } else { Directory('${appDir.path}/' + filename)..create(recursive: true); } - }); + }; await _verifyWallets(); await _importKeychainDumpV2(password);