This commit is contained in:
Manav Rathi 2024-04-13 16:57:04 +05:30
parent 284d7920b3
commit c90ba63aad
No known key found for this signature in database
3 changed files with 11 additions and 16 deletions

View file

@ -32,7 +32,6 @@ import {
getDeletedExportedCollections,
getDeletedExportedFiles,
getExportRecordFileUID,
getFileExportPath,
getFileMetadataExportPath,
getGoogleLikeMetadataFile,
getLivePhotoExportName,
@ -1202,3 +1201,8 @@ class ExportService {
}
export default new ExportService();
export const getFileExportPath = (
collectionExportPath: string,
fileExportName: string,
) => `${collectionExportPath}/${fileExportName}`;

View file

@ -219,9 +219,7 @@ export const getUniqueFileExportName = async (
let fileExportName = sanitizeName(filename);
let count = 1;
while (
await exportService.exists(
getFileExportPath(collectionExportPath, fileExportName),
)
await exportService.exists(`${collectionExportPath}/${fileExportName}`)
) {
const filenameParts = splitFilenameAndExtension(sanitizeName(filename));
if (filenameParts[1]) {
@ -239,11 +237,6 @@ export const getFileMetadataExportPath = (
fileExportName: string,
) => `${collectionExportPath}/${ENTE_METADATA_FOLDER}/${fileExportName}.json`;
export const getFileExportPath = (
collectionExportPath: string,
fileExportName: string,
) => `${collectionExportPath}/${fileExportName}`;
export const getTrashedFileExportPath = async (
exportDir: string,
path: string,

View file

@ -51,7 +51,7 @@ import {
} from "types/gallery";
import { VISIBILITY_STATE } from "types/magicMetadata";
import { FileTypeInfo } from "types/upload";
import { getFileExportPath, getUniqueFileExportName } from "utils/export";
import { getUniqueFileExportName } from "utils/export";
import { isArchivedFile, updateMagicMetadata } from "utils/magicMetadata";
const WAIT_TIME_IMAGE_CONVERSION = 30 * 1000;
@ -818,7 +818,7 @@ async function downloadFileDesktop(
);
const imageStream = generateStreamFromArrayBuffer(livePhoto.image);
await electron.saveStreamToDisk(
getFileExportPath(downloadPath, imageExportName),
`${downloadPath}/${imageExportName}`,
imageStream,
);
try {
@ -828,13 +828,11 @@ async function downloadFileDesktop(
);
const videoStream = generateStreamFromArrayBuffer(livePhoto.video);
await electron.saveStreamToDisk(
getFileExportPath(downloadPath, videoExportName),
`${downloadPath}/${videoExportName}`,
videoStream,
);
} catch (e) {
await electron.deleteFile(
getFileExportPath(downloadPath, imageExportName),
);
await electron.deleteFile(`${downloadPath}/${imageExportName}`);
throw e;
}
} else {
@ -843,7 +841,7 @@ async function downloadFileDesktop(
file.metadata.title,
);
await electron.saveStreamToDisk(
getFileExportPath(downloadPath, fileExportName),
`${downloadPath}/${fileExportName}`,
updatedFileStream,
);
}