From 3824ebe91aed033d8492dbca8fc784c30c6a6e15 Mon Sep 17 00:00:00 2001 From: Manav Rathi Date: Sun, 14 Apr 2024 09:55:41 +0530 Subject: [PATCH] Remove exportService indirection --- web/apps/photos/src/services/export/index.ts | 4 ++-- web/apps/photos/src/services/export/migration.ts | 9 +++++---- 2 files changed, 7 insertions(+), 6 deletions(-) diff --git a/web/apps/photos/src/services/export/index.ts b/web/apps/photos/src/services/export/index.ts index d1b614dd17..4fe7812a8b 100644 --- a/web/apps/photos/src/services/export/index.ts +++ b/web/apps/photos/src/services/export/index.ts @@ -1141,12 +1141,12 @@ class ExportService { file, ); try { - await ensureElectron().saveStreamToDisk( + await electron.saveStreamToDisk( `${collectionExportPath}/${videoExportName}`, videoStream, ); } catch (e) { - await ensureElectron().deleteFile( + await electron.deleteFile( `${collectionExportPath}/${imageExportName}`, ); throw e; diff --git a/web/apps/photos/src/services/export/migration.ts b/web/apps/photos/src/services/export/migration.ts index 886c516147..53f8131c42 100644 --- a/web/apps/photos/src/services/export/migration.ts +++ b/web/apps/photos/src/services/export/migration.ts @@ -246,10 +246,10 @@ async function migrateFiles( const newFilePath = `${collectionPath}/${newFileName}`; const newFileMetadataPath = `${metadataPath}/${newFileName}.json`; - if (!(await exportService.exists(oldFilePath))) continue; + if (!(await fs.exists(oldFilePath))) continue; - await exportService.rename(oldFilePath, newFilePath); - await exportService.rename(oldFileMetadataPath, newFileMetadataPath); + await fs.rename(oldFilePath, newFilePath); + await fs.rename(oldFileMetadataPath, newFileMetadataPath); } } @@ -409,6 +409,7 @@ async function removeCollectionExportMissingMetadataFolder( exportDir: string, exportRecord: ExportRecord, ) { + const fs = ensureElectron().fs; if (!exportRecord?.collectionExportNames) { return; } @@ -422,7 +423,7 @@ async function removeCollectionExportMissingMetadataFolder( collectionExportName, ] of properlyExportedCollectionsAll) { if ( - await exportService.exists( + await fs.exists( getMetadataFolderExportPath( `${exportDir}/${collectionExportName}`, ),