Skip to content

armgit / ente

Public Imported from GitHub
0

πŸ’š End-to-end encrypted cloud for everything.

Make explicit

Manav Rathi7838f7484d12
diff --git a/web/apps/photos/src/utils/native-fs.ts b/web/apps/photos/src/utils/native-fs.ts
index 4173aa7ac0..f52dea81ea 100644
--- a/web/apps/photos/src/utils/native-fs.ts
+++ b/web/apps/photos/src/utils/native-fs.ts
@@ -1,5 +1,5 @@
+import { ensureElectron } from "@/next/electron";
import sanitize from "sanitize-filename";
-import exportService from "services/export";
import { splitFilenameAndExtension } from "utils/file";
export const ENTE_TRASH_FOLDER = "Trash";
@@ -7,6 +7,8 @@ export const ENTE_TRASH_FOLDER = "Trash";
export const sanitizeName = (name: string) =>
sanitize(name, { replacement: "_" });
+const exists = (path: string) => ensureElectron().fs.exists(path);
+
export const getUniqueCollectionExportName = async (
dir: string,
collectionName: string,
@@ -14,7 +16,7 @@ export const getUniqueCollectionExportName = async (
let collectionExportName = sanitizeName(collectionName);
let count = 1;
while (
- (await exportService.exists(`${dir}/${collectionExportName}`)) ||
+ (await exists(`${dir}/${collectionExportName}`)) ||
collectionExportName === ENTE_TRASH_FOLDER
) {
collectionExportName = `${sanitizeName(collectionName)}(${count})`;
@@ -29,9 +31,7 @@ export const getUniqueFileExportName = async (
) => {
let fileExportName = sanitizeName(filename);
let count = 1;
- while (
- await exportService.exists(`${collectionExportPath}/${fileExportName}`)
- ) {
+ while (await exists(`${collectionExportPath}/${fileExportName}`)) {
const filenameParts = splitFilenameAndExtension(sanitizeName(filename));
if (filenameParts[1]) {
fileExportName = `${filenameParts[0]}(${count}).${filenameParts[1]}`;