Skip to content

Commit d0779e0

Browse files
committed
refactor(backup): simplify file handling in createBackup and restoreBackup functions
1 parent 87c3ebf commit d0779e0

1 file changed

Lines changed: 2 additions & 14 deletions

File tree

src/services/backup/local/index.ts

Lines changed: 2 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -182,20 +182,12 @@ export const createBackup = async (
182182
);
183183
}
184184

185-
const zipFileUri = 'file://' + zipPath;
186-
187185
try {
188186
if (!(await NativeFile.exists(zipPath))) {
189187
throw new Error('Backup zip file was not created');
190188
}
191189

192-
const zipData = await FileSystem.readAsStringAsync(zipFileUri, {
193-
encoding: FileSystem.EncodingType.Base64,
194-
});
195-
196-
await FileSystem.writeAsStringAsync(fileUri, zipData, {
197-
encoding: FileSystem.EncodingType.Base64,
198-
});
190+
await NativeFile.copyFile(zipPath, fileUri);
199191

200192
const backupTypeText = includeDownloads ? ' (with downloads)' : '';
201193

@@ -491,11 +483,7 @@ export const restoreBackup = async (
491483
await NativeFile.unlink(tempZipPath);
492484
}
493485

494-
const zipData = await FileSystem.readAsStringAsync(backupFile.uri, {
495-
encoding: FileSystem.EncodingType.Base64,
496-
});
497-
498-
await NativeFile.writeFile(tempZipPath, zipData);
486+
await NativeFile.copyFile(backupFile.uri, tempZipPath);
499487

500488
if (!(await NativeFile.exists(tempZipPath))) {
501489
throw new Error('Failed to create temporary backup file');

0 commit comments

Comments
 (0)