improve error logging
This commit is contained in:
parent
84a2a00c61
commit
60fcf46c63
|
@ -241,6 +241,7 @@ class ExportService {
|
||||||
RecordType.SUCCESS
|
RecordType.SUCCESS
|
||||||
);
|
);
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
|
logError(e, 'export failed for a file');
|
||||||
if (
|
if (
|
||||||
e.message ===
|
e.message ===
|
||||||
CustomError.ADD_FILE_EXPORTED_RECORD_FAILED
|
CustomError.ADD_FILE_EXPORTED_RECORD_FAILED
|
||||||
|
@ -252,11 +253,6 @@ class ExportService {
|
||||||
file,
|
file,
|
||||||
RecordType.FAILED
|
RecordType.FAILED
|
||||||
);
|
);
|
||||||
|
|
||||||
logError(
|
|
||||||
e,
|
|
||||||
'download and save failed for file during export'
|
|
||||||
);
|
|
||||||
}
|
}
|
||||||
this.electronAPIs.showOnTray({
|
this.electronAPIs.showOnTray({
|
||||||
export_progress: `${index + 1} / ${
|
export_progress: `${index + 1} / ${
|
||||||
|
@ -446,36 +442,45 @@ class ExportService {
|
||||||
}
|
}
|
||||||
|
|
||||||
async downloadAndSave(file: EnteFile, collectionPath: string) {
|
async downloadAndSave(file: EnteFile, collectionPath: string) {
|
||||||
file.metadata = mergeMetadata([file])[0].metadata;
|
try {
|
||||||
const fileSaveName = getUniqueFileSaveName(
|
file.metadata = mergeMetadata([file])[0].metadata;
|
||||||
collectionPath,
|
const fileSaveName = getUniqueFileSaveName(
|
||||||
file.metadata.title,
|
collectionPath,
|
||||||
file.id
|
file.metadata.title,
|
||||||
);
|
file.id
|
||||||
let fileStream = await retryAsyncFunction(() =>
|
|
||||||
downloadManager.downloadFile(file)
|
|
||||||
);
|
|
||||||
const fileType = getFileExtension(file.metadata.title);
|
|
||||||
if (
|
|
||||||
file.pubMagicMetadata?.data.editedTime &&
|
|
||||||
(fileType === TYPE_JPEG || fileType === TYPE_JPG)
|
|
||||||
) {
|
|
||||||
const fileBlob = await new Response(fileStream).blob();
|
|
||||||
if (!this.fileReader) {
|
|
||||||
this.fileReader = new FileReader();
|
|
||||||
}
|
|
||||||
const updatedFileBlob = await updateFileCreationDateInEXIF(
|
|
||||||
this.fileReader,
|
|
||||||
fileBlob,
|
|
||||||
new Date(file.pubMagicMetadata.data.editedTime / 1000)
|
|
||||||
);
|
);
|
||||||
fileStream = updatedFileBlob.stream();
|
let fileStream = await retryAsyncFunction(() =>
|
||||||
}
|
downloadManager.downloadFile(file)
|
||||||
if (file.metadata.fileType === FILE_TYPE.LIVE_PHOTO) {
|
);
|
||||||
await this.exportMotionPhoto(fileStream, file, collectionPath);
|
const fileType = getFileExtension(file.metadata.title);
|
||||||
} else {
|
if (
|
||||||
await this.saveMediaFile(collectionPath, fileSaveName, fileStream);
|
file.pubMagicMetadata?.data.editedTime &&
|
||||||
await this.saveMetadataFile(collectionPath, fileSaveName, file);
|
(fileType === TYPE_JPEG || fileType === TYPE_JPG)
|
||||||
|
) {
|
||||||
|
const fileBlob = await new Response(fileStream).blob();
|
||||||
|
if (!this.fileReader) {
|
||||||
|
this.fileReader = new FileReader();
|
||||||
|
}
|
||||||
|
const updatedFileBlob = await updateFileCreationDateInEXIF(
|
||||||
|
this.fileReader,
|
||||||
|
fileBlob,
|
||||||
|
new Date(file.pubMagicMetadata.data.editedTime / 1000)
|
||||||
|
);
|
||||||
|
fileStream = updatedFileBlob.stream();
|
||||||
|
}
|
||||||
|
if (file.metadata.fileType === FILE_TYPE.LIVE_PHOTO) {
|
||||||
|
await this.exportMotionPhoto(fileStream, file, collectionPath);
|
||||||
|
} else {
|
||||||
|
await this.saveMediaFile(
|
||||||
|
collectionPath,
|
||||||
|
fileSaveName,
|
||||||
|
fileStream
|
||||||
|
);
|
||||||
|
await this.saveMetadataFile(collectionPath, fileSaveName, file);
|
||||||
|
}
|
||||||
|
} catch (e) {
|
||||||
|
logError(e, 'download and save failed');
|
||||||
|
throw e;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue