Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(media-store): only ignore File Not Exist error #2339

Merged
merged 2 commits into from
Nov 28, 2022
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
23 changes: 19 additions & 4 deletions src/app/shared/media/media-store/media-store.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -127,10 +127,25 @@ export class MediaStore {
await this.deleteThumbnail(index);
return this.mutex.runExclusive(async () => {
const extension = await this.getExtension(index);
await this.filesystemPlugin.deleteFile({
directory: this.directory,
path: `${this.rootDir}/${index}.${extension}`,
});
try {
await this.filesystemPlugin.deleteFile({
directory: this.directory,
path: `${this.rootDir}/${index}.${extension}`,
});
} catch (error: any) {
/* WORKAROUND
* In capture app we get "File does not exist error"
* if currentPlatform.isAndroid() === true &&
* fileToBeDeleted.isCapturedFromIphone() === true
* When we delete capture from iPhone that was captured
* by Android "File does not exists" is not thrown.
* So we can silently ignore "File does not exist" error
* while deleting capture from FileSystem only.
*/
if (error.message !== 'File does not exist') {
throw error;
}
}
await this.deleteMediaExtension(index);
return index;
});
Expand Down