diff --git a/desktop/src/main/services/ffmpeg.ts b/desktop/src/main/services/ffmpeg.ts index 0a5c4eed2..6b1171459 100644 --- a/desktop/src/main/services/ffmpeg.ts +++ b/desktop/src/main/services/ffmpeg.ts @@ -69,7 +69,7 @@ export const ffmpegExec = async ( outputFilePath, ); - if (timeoutMS) await withTimeout(execAsync(cmd), 30 * 1000); + if (timeoutMS) await withTimeout(execAsync(cmd), timeoutMS); else await execAsync(cmd); return fs.readFile(outputFilePath); diff --git a/web/apps/photos/src/services/export/index.ts b/web/apps/photos/src/services/export/index.ts index b02e05a42..786932ff8 100644 --- a/web/apps/photos/src/services/export/index.ts +++ b/web/apps/photos/src/services/export/index.ts @@ -734,38 +734,31 @@ class ExportService { const collectionExportName = collectionIDExportNameMap.get(collectionID); - await this.removeFileExportedRecord(exportDir, fileUID); - try { - if (isLivePhotoExportName(fileExportName)) { - const { image, video } = - parseLivePhotoExportName(fileExportName); + if (isLivePhotoExportName(fileExportName)) { + const { image, video } = + parseLivePhotoExportName(fileExportName); - await moveToTrash( - exportDir, - collectionExportName, - image, - ); - - await moveToTrash( - exportDir, - collectionExportName, - video, - ); - } else { - await moveToTrash( - exportDir, - collectionExportName, - fileExportName, - ); - } - } catch (e) { - await this.addFileExportedRecord( + await moveToTrash( exportDir, - fileUID, + collectionExportName, + image, + ); + + await moveToTrash( + exportDir, + collectionExportName, + video, + ); + } else { + await moveToTrash( + exportDir, + collectionExportName, fileExportName, ); - throw e; } + + await this.removeFileExportedRecord(exportDir, fileUID); + log.info(`Moved file id ${fileUID} to Trash`); } catch (e) { log.error("trashing failed for a file", e); @@ -985,26 +978,21 @@ class ExportService { file.metadata.title, electron.fs.exists, ); + await this.saveMetadataFile( + collectionExportPath, + fileExportName, + file, + ); + await writeStream( + electron, + `${collectionExportPath}/${fileExportName}`, + updatedFileStream, + ); await this.addFileExportedRecord( exportDir, fileUID, fileExportName, ); - try { - await this.saveMetadataFile( - collectionExportPath, - fileExportName, - file, - ); - await writeStream( - electron, - `${collectionExportPath}/${fileExportName}`, - updatedFileStream, - ); - } catch (e) { - await this.removeFileExportedRecord(exportDir, fileUID); - throw e; - } } } catch (e) { log.error("download and save failed", e); @@ -1032,52 +1020,46 @@ class ExportService { livePhoto.videoFileName, fs.exists, ); + const livePhotoExportName = getLivePhotoExportName( imageExportName, videoExportName, ); + + const imageStream = generateStreamFromArrayBuffer(livePhoto.imageData); + await this.saveMetadataFile( + collectionExportPath, + imageExportName, + file, + ); + await writeStream( + electron, + `${collectionExportPath}/${imageExportName}`, + imageStream, + ); + + const videoStream = generateStreamFromArrayBuffer(livePhoto.videoData); + await this.saveMetadataFile( + collectionExportPath, + videoExportName, + file, + ); + try { + await writeStream( + electron, + `${collectionExportPath}/${videoExportName}`, + videoStream, + ); + } catch (e) { + await fs.rm(`${collectionExportPath}/${imageExportName}`); + throw e; + } + await this.addFileExportedRecord( exportDir, fileUID, livePhotoExportName, ); - try { - const imageStream = generateStreamFromArrayBuffer( - livePhoto.imageData, - ); - await this.saveMetadataFile( - collectionExportPath, - imageExportName, - file, - ); - await writeStream( - electron, - `${collectionExportPath}/${imageExportName}`, - imageStream, - ); - - const videoStream = generateStreamFromArrayBuffer( - livePhoto.videoData, - ); - await this.saveMetadataFile( - collectionExportPath, - videoExportName, - file, - ); - try { - await writeStream( - electron, - `${collectionExportPath}/${videoExportName}`, - videoStream, - ); - } catch (e) { - await fs.rm(`${collectionExportPath}/${imageExportName}`); - throw e; - } - } catch (e) { - await this.removeFileExportedRecord(exportDir, fileUID); - throw e; - } } private async saveMetadataFile(