check if file exists before attempting move
This commit is contained in:
parent
a0eb196e05
commit
06eef0758c
|
@ -789,24 +789,28 @@ class ExportService {
|
||||||
addLogLine(
|
addLogLine(
|
||||||
`moving image file ${imageExportPath} to trash folder`
|
`moving image file ${imageExportPath} to trash folder`
|
||||||
);
|
);
|
||||||
await this.electronAPIs.moveFile(
|
if (this.exists(imageExportPath)) {
|
||||||
imageExportPath,
|
await this.electronAPIs.moveFile(
|
||||||
getTrashedFileExportPath(
|
imageExportPath,
|
||||||
exportDir,
|
getTrashedFileExportPath(
|
||||||
imageExportPath
|
exportDir,
|
||||||
)
|
imageExportPath
|
||||||
);
|
)
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
const imageMetadataFileExportPath =
|
const imageMetadataFileExportPath =
|
||||||
getMetadataFileExportPath(imageExportPath);
|
getMetadataFileExportPath(imageExportPath);
|
||||||
|
|
||||||
await this.electronAPIs.moveFile(
|
if (this.exists(imageMetadataFileExportPath)) {
|
||||||
imageMetadataFileExportPath,
|
await this.electronAPIs.moveFile(
|
||||||
getTrashedFileExportPath(
|
imageMetadataFileExportPath,
|
||||||
exportDir,
|
getTrashedFileExportPath(
|
||||||
imageMetadataFileExportPath
|
exportDir,
|
||||||
)
|
imageMetadataFileExportPath
|
||||||
);
|
)
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
const videoExportPath = getFileExportPath(
|
const videoExportPath = getFileExportPath(
|
||||||
collectionExportPath,
|
collectionExportPath,
|
||||||
|
@ -815,22 +819,26 @@ class ExportService {
|
||||||
addLogLine(
|
addLogLine(
|
||||||
`moving video file ${videoExportPath} to trash folder`
|
`moving video file ${videoExportPath} to trash folder`
|
||||||
);
|
);
|
||||||
await this.electronAPIs.moveFile(
|
if (this.exists(videoExportPath)) {
|
||||||
videoExportPath,
|
await this.electronAPIs.moveFile(
|
||||||
getTrashedFileExportPath(
|
videoExportPath,
|
||||||
exportDir,
|
getTrashedFileExportPath(
|
||||||
videoExportPath
|
exportDir,
|
||||||
)
|
videoExportPath
|
||||||
);
|
)
|
||||||
|
);
|
||||||
|
}
|
||||||
const videoMetadataFileExportPath =
|
const videoMetadataFileExportPath =
|
||||||
getMetadataFileExportPath(videoExportPath);
|
getMetadataFileExportPath(videoExportPath);
|
||||||
await this.electronAPIs.moveFile(
|
if (this.exists(videoMetadataFileExportPath)) {
|
||||||
videoMetadataFileExportPath,
|
await this.electronAPIs.moveFile(
|
||||||
getTrashedFileExportPath(
|
videoMetadataFileExportPath,
|
||||||
exportDir,
|
getTrashedFileExportPath(
|
||||||
videoMetadataFileExportPath
|
exportDir,
|
||||||
)
|
videoMetadataFileExportPath
|
||||||
);
|
)
|
||||||
|
);
|
||||||
|
}
|
||||||
} else {
|
} else {
|
||||||
const fileExportPath = getFileExportPath(
|
const fileExportPath = getFileExportPath(
|
||||||
collectionExportPath,
|
collectionExportPath,
|
||||||
|
@ -843,19 +851,23 @@ class ExportService {
|
||||||
addLogLine(
|
addLogLine(
|
||||||
`moving file ${fileExportPath} to ${trashedFilePath} trash folder`
|
`moving file ${fileExportPath} to ${trashedFilePath} trash folder`
|
||||||
);
|
);
|
||||||
await this.electronAPIs.moveFile(
|
if (this.exists(fileExportPath)) {
|
||||||
fileExportPath,
|
await this.electronAPIs.moveFile(
|
||||||
trashedFilePath
|
fileExportPath,
|
||||||
);
|
trashedFilePath
|
||||||
|
);
|
||||||
|
}
|
||||||
const metadataFileExportPath =
|
const metadataFileExportPath =
|
||||||
getMetadataFileExportPath(fileExportPath);
|
getMetadataFileExportPath(fileExportPath);
|
||||||
await this.electronAPIs.moveFile(
|
if (this.exists(metadataFileExportPath)) {
|
||||||
metadataFileExportPath,
|
await this.electronAPIs.moveFile(
|
||||||
getTrashedFileExportPath(
|
metadataFileExportPath,
|
||||||
exportDir,
|
getTrashedFileExportPath(
|
||||||
metadataFileExportPath
|
exportDir,
|
||||||
)
|
metadataFileExportPath
|
||||||
);
|
)
|
||||||
|
);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
await this.addFileExportedRecord(
|
await this.addFileExportedRecord(
|
||||||
|
|
Loading…
Reference in a new issue