π End-to-end encrypted cloud for everything.
Dart 2faandroidauthye2eeencryptionend-to-end-encryptionfluttergolanggoogle-photosgoogle-photos-alternativeiosopensourcephotosprivacyprivacy-toolstypescriptzero-knowledge
Restructure selection
Manav Rathia5f9fdd10d33
diff --git a/web/apps/photos/src/components/ExportModal.tsx b/web/apps/photos/src/components/ExportModal.tsxindex 7b20dd0965..ae0de37a6c 100644--- a/web/apps/photos/src/components/ExportModal.tsx+++ b/web/apps/photos/src/components/ExportModal.tsx@@ -18,7 +18,10 @@ import { t } from "i18next";import isElectron from "is-electron";import { AppContext } from "pages/_app";import { useContext, useEffect, useState } from "react";-import exportService, { ExportStage } from "services/export";+import exportService, {+ ExportStage,+ selectAndPrepareExportDirectory,+} from "services/export";import { ExportProgress, ExportSettings } from "types/export";import { EnteFile } from "types/file";import { getExportDirectoryDoesNotExistMessage } from "utils/ui";@@ -117,17 +120,13 @@ export default function ExportModal(props: Props) {// =============const handleChangeExportDirectoryClick = async () => {- try {- const newFolder = await exportService.changeExportDirectory();- log.info(`Export folder changed to ${newFolder}`);- exportService.updateExportSettings({ folder: newFolder });- setExportFolder(newFolder);- void syncExportRecord(newFolder);- } catch (e) {- if (e.message !== CustomError.SELECT_FOLDER_ABORTED) {- log.error("handleChangeExportDirectoryClick failed", e);- }- }+ const newFolder = await selectAndPrepareExportDirectory();+ if (!newFolder) return;++ log.info(`Export folder changed to ${newFolder}`);+ exportService.updateExportSettings({ folder: newFolder });+ setExportFolder(newFolder);+ await syncExportRecord(newFolder);};const toggleContinuousExport = async () => {diff --git a/web/apps/photos/src/services/export/index.ts b/web/apps/photos/src/services/export/index.tsindex c21c2d2991..a0b3789ce2 100644--- a/web/apps/photos/src/services/export/index.ts+++ b/web/apps/photos/src/services/export/index.ts@@ -165,24 +165,6 @@ class ExportService {this.uiUpdater.setLastExportTime(exportTime);}- async changeExportDirectory() {- const electron = ensureElectron();- try {- const newRootDir = await electron.selectDirectory();- if (!newRootDir) {- throw Error(CustomError.SELECT_FOLDER_ABORTED);- }- const newExportDir = `${newRootDir}/${exportDirectoryName}`;- await electron.fs.mkdirIfNeeded(newExportDir);- return newExportDir;- } catch (e) {- if (e.message !== CustomError.SELECT_FOLDER_ABORTED) {- log.error("changeExportDirectory failed", e);- }- throw e;- }- }-enableContinuousExport() {try {if (this.continuousExportEventHandler) {@@ -1158,6 +1140,24 @@ export const resumeExportsIfNeeded = async () => {}};+/**+ * Prompt the user to select a directory and create an export directory in it.+ *+ * If the user cancels the selection, return undefined.+ */+export const selectAndPrepareExportDirectory = async (): Promise<+ string | undefined+> => {+ const electron = ensureElectron();++ const rootDir = await electron.selectDirectory();+ if (!rootDir) return undefined;++ const exportDir = `${rootDir}/${exportDirectoryName}`;+ await electron.fs.mkdirIfNeeded(exportDir);+ return exportDir;+};+export const getExportRecordFileUID = (file: EnteFile) =>`${file.id}_${file.collectionID}_${file.updationTime}`;