[desktop] Misc fixes (#1650)
This commit is contained in:
commit
40abb5c0ac
2 changed files with 62 additions and 80 deletions
|
@ -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);
|
||||
|
|
|
@ -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(
|
||||
|
|
Loading…
Add table
Reference in a new issue