|
@@ -485,6 +485,7 @@ class ExportService {
|
|
renamedCollections: Collection[],
|
|
renamedCollections: Collection[],
|
|
isCanceled: CancellationStatus,
|
|
isCanceled: CancellationStatus,
|
|
) {
|
|
) {
|
|
|
|
+ const fs = ensureElectron().fs;
|
|
try {
|
|
try {
|
|
for (const collection of renamedCollections) {
|
|
for (const collection of renamedCollections) {
|
|
try {
|
|
try {
|
|
@@ -498,6 +499,7 @@ class ExportService {
|
|
const newCollectionExportName = await safeDirectoryName(
|
|
const newCollectionExportName = await safeDirectoryName(
|
|
exportFolder,
|
|
exportFolder,
|
|
getCollectionUserFacingName(collection),
|
|
getCollectionUserFacingName(collection),
|
|
|
|
+ fs.exists,
|
|
);
|
|
);
|
|
log.info(
|
|
log.info(
|
|
`renaming collection with id ${collection.id} from ${oldCollectionExportName} to ${newCollectionExportName}`,
|
|
`renaming collection with id ${collection.id} from ${oldCollectionExportName} to ${newCollectionExportName}`,
|
|
@@ -513,7 +515,7 @@ class ExportService {
|
|
newCollectionExportName,
|
|
newCollectionExportName,
|
|
);
|
|
);
|
|
try {
|
|
try {
|
|
- await ensureElectron().fs.rename(
|
|
|
|
|
|
+ await fs.rename(
|
|
oldCollectionExportPath,
|
|
oldCollectionExportPath,
|
|
newCollectionExportPath,
|
|
newCollectionExportPath,
|
|
);
|
|
);
|
|
@@ -1017,15 +1019,17 @@ class ExportService {
|
|
collectionID: number,
|
|
collectionID: number,
|
|
collectionIDNameMap: Map<number, string>,
|
|
collectionIDNameMap: Map<number, string>,
|
|
) {
|
|
) {
|
|
|
|
+ const electron = ensureElectron();
|
|
await this.verifyExportFolderExists(exportFolder);
|
|
await this.verifyExportFolderExists(exportFolder);
|
|
const collectionName = collectionIDNameMap.get(collectionID);
|
|
const collectionName = collectionIDNameMap.get(collectionID);
|
|
const collectionExportName = await safeDirectoryName(
|
|
const collectionExportName = await safeDirectoryName(
|
|
exportFolder,
|
|
exportFolder,
|
|
collectionName,
|
|
collectionName,
|
|
|
|
+ electron.fs.exists,
|
|
);
|
|
);
|
|
const collectionExportPath = `${exportFolder}/${collectionExportName}`;
|
|
const collectionExportPath = `${exportFolder}/${collectionExportName}`;
|
|
- await ensureElectron().checkExistsAndCreateDir(collectionExportPath);
|
|
|
|
- await ensureElectron().checkExistsAndCreateDir(
|
|
|
|
|
|
+ await electron.checkExistsAndCreateDir(collectionExportPath);
|
|
|
|
+ await electron.checkExistsAndCreateDir(
|
|
getMetadataFolderExportPath(collectionExportPath),
|
|
getMetadataFolderExportPath(collectionExportPath),
|
|
);
|
|
);
|
|
|
|
|
|
@@ -1037,6 +1041,7 @@ class ExportService {
|
|
collectionExportPath: string,
|
|
collectionExportPath: string,
|
|
file: EnteFile,
|
|
file: EnteFile,
|
|
): Promise<void> {
|
|
): Promise<void> {
|
|
|
|
+ const electron = ensureElectron();
|
|
try {
|
|
try {
|
|
const fileUID = getExportRecordFileUID(file);
|
|
const fileUID = getExportRecordFileUID(file);
|
|
const originalFileStream = await downloadManager.getFile(file);
|
|
const originalFileStream = await downloadManager.getFile(file);
|
|
@@ -1060,6 +1065,7 @@ class ExportService {
|
|
const fileExportName = await safeFileName(
|
|
const fileExportName = await safeFileName(
|
|
collectionExportPath,
|
|
collectionExportPath,
|
|
file.metadata.title,
|
|
file.metadata.title,
|
|
|
|
+ electron.fs.exists,
|
|
);
|
|
);
|
|
await this.addFileExportedRecord(
|
|
await this.addFileExportedRecord(
|
|
exportDir,
|
|
exportDir,
|
|
@@ -1072,7 +1078,7 @@ class ExportService {
|
|
fileExportName,
|
|
fileExportName,
|
|
file,
|
|
file,
|
|
);
|
|
);
|
|
- await ensureElectron().saveStreamToDisk(
|
|
|
|
|
|
+ await electron.saveStreamToDisk(
|
|
`${collectionExportPath}/${fileExportName}`,
|
|
`${collectionExportPath}/${fileExportName}`,
|
|
updatedFileStream,
|
|
updatedFileStream,
|
|
);
|
|
);
|
|
@@ -1094,15 +1100,18 @@ class ExportService {
|
|
fileStream: ReadableStream<any>,
|
|
fileStream: ReadableStream<any>,
|
|
file: EnteFile,
|
|
file: EnteFile,
|
|
) {
|
|
) {
|
|
|
|
+ const electron = ensureElectron();
|
|
const fileBlob = await new Response(fileStream).blob();
|
|
const fileBlob = await new Response(fileStream).blob();
|
|
const livePhoto = await decodeLivePhoto(file, fileBlob);
|
|
const livePhoto = await decodeLivePhoto(file, fileBlob);
|
|
const imageExportName = await safeFileName(
|
|
const imageExportName = await safeFileName(
|
|
collectionExportPath,
|
|
collectionExportPath,
|
|
livePhoto.imageNameTitle,
|
|
livePhoto.imageNameTitle,
|
|
|
|
+ electron.fs.exists,
|
|
);
|
|
);
|
|
const videoExportName = await safeFileName(
|
|
const videoExportName = await safeFileName(
|
|
collectionExportPath,
|
|
collectionExportPath,
|
|
livePhoto.videoNameTitle,
|
|
livePhoto.videoNameTitle,
|
|
|
|
+ electron.fs.exists,
|
|
);
|
|
);
|
|
const livePhotoExportName = getLivePhotoExportName(
|
|
const livePhotoExportName = getLivePhotoExportName(
|
|
imageExportName,
|
|
imageExportName,
|
|
@@ -1120,7 +1129,7 @@ class ExportService {
|
|
imageExportName,
|
|
imageExportName,
|
|
file,
|
|
file,
|
|
);
|
|
);
|
|
- await ensureElectron().saveStreamToDisk(
|
|
|
|
|
|
+ await electron.saveStreamToDisk(
|
|
`${collectionExportPath}/${imageExportName}`,
|
|
`${collectionExportPath}/${imageExportName}`,
|
|
imageStream,
|
|
imageStream,
|
|
);
|
|
);
|