create ente Photos wrapper folder for export

This commit is contained in:
Abhinav 2023-03-23 11:20:34 +05:30
parent f31d94e2cb
commit 6abe03767d
2 changed files with 17 additions and 14 deletions

View file

@ -186,15 +186,8 @@ export default function ExportModal(props: Props) {
// UI functions
// =============
const changeExportDirectory = async () => {
try {
const newFolder = await exportService.selectExportDirectory();
if (newFolder) {
updateExportFolder(newFolder);
}
} catch (e) {
logError(e, 'selectExportDirectory failed');
}
const changeExportDirectory = () => {
void exportService.changeExportDirectory(updateExportFolder);
};
const toggleContinuousExport = () => {
@ -225,7 +218,7 @@ export default function ExportModal(props: Props) {
await postExportRun();
} catch (e) {
logError(e, 'resumeExport failed');
logError(e, 'startExport failed');
}
};

View file

@ -54,6 +54,8 @@ import { eventBus, Events } from './events';
const EXPORT_RECORD_FILE_NAME = 'export_status.json';
export const ENTE_EXPORT_DIRECTORY = 'ente Photos';
class ExportService {
private electronAPIs: ElectronAPIs;
private exportInProgress: Promise<void> = null;
@ -67,12 +69,20 @@ class ExportService {
this.electronAPIs = runningInBrowser() && window['ElectronAPIs'];
this.allElectronAPIsExist = !!this.electronAPIs?.exists;
}
async selectExportDirectory() {
async changeExportDirectory(callback: (newExportDir: string) => void) {
try {
return await this.electronAPIs.selectRootDirectory();
const newRootDir = await this.electronAPIs.selectRootDirectory();
if (!newRootDir) {
return;
}
const newExportDir = `${newRootDir}/${ENTE_EXPORT_DIRECTORY}`;
await this.electronAPIs.checkExistsAndCreateCollectionDir(
newExportDir
);
callback(newExportDir);
} catch (e) {
logError(e, 'failed to selectExportDirectory ');
throw e;
logError(e, 'changeExportDirectory failed');
}
}