Handle removal of invalid files
This commit is contained in:
parent
c5ed2cabcf
commit
268dd311ae
|
@ -60,9 +60,7 @@ const useServerStorage = () => {
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
Sentry.captureException(error);
|
Sentry.captureException(error);
|
||||||
console.error(error);
|
console.error(error);
|
||||||
|
return Promise.reject(error);
|
||||||
// suppress error, may happen on mobile
|
|
||||||
return Promise.resolve();
|
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
|
@ -354,18 +354,30 @@ const UploadPage = () => {
|
||||||
});
|
});
|
||||||
};
|
};
|
||||||
|
|
||||||
const removeFileFromStorage = async (fileId: string) => {
|
const removeFileFromStorage = async (fileId: string | null): Promise<boolean> => {
|
||||||
|
if (!fileId) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
await removeFile(await getBucketId(currentUser!.$id), fileId);
|
await removeFile(await getBucketId(currentUser!.$id), fileId);
|
||||||
|
|
||||||
|
return true;
|
||||||
};
|
};
|
||||||
|
|
||||||
const removeTuneFile = async () => {
|
const removeTuneFile = async () => {
|
||||||
await removeFileFromStorage(tuneFileId!);
|
if (!await removeFileFromStorage(tuneFileId!)) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
await updateTune(tuneDocumentId!, { tuneFileId: null });
|
await updateTune(tuneDocumentId!, { tuneFileId: null });
|
||||||
setTuneFileId(null);
|
setTuneFileId(null);
|
||||||
};
|
};
|
||||||
|
|
||||||
const removeLogFile = async (file: UploadFile) => {
|
const removeLogFile = async (file: UploadFile) => {
|
||||||
await removeFileFromStorage(logFileIds.get(file.uid)!);
|
if (!await removeFileFromStorage(logFileIds.get(file.uid)!)) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
logFileIds.delete(file.uid);
|
logFileIds.delete(file.uid);
|
||||||
const newValues = new Map(logFileIds);
|
const newValues = new Map(logFileIds);
|
||||||
setLogFileIds(newValues);
|
setLogFileIds(newValues);
|
||||||
|
@ -373,7 +385,10 @@ const UploadPage = () => {
|
||||||
};
|
};
|
||||||
|
|
||||||
const removeToothLogFile = async (file: UploadFile) => {
|
const removeToothLogFile = async (file: UploadFile) => {
|
||||||
await removeFileFromStorage(toothLogFileIds.get(file.uid)!);
|
if (!await removeFileFromStorage(toothLogFileIds.get(file.uid)!)) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
toothLogFileIds.delete(file.uid);
|
toothLogFileIds.delete(file.uid);
|
||||||
const newValues = new Map(toothLogFileIds);
|
const newValues = new Map(toothLogFileIds);
|
||||||
setToothLogFileIds(newValues);
|
setToothLogFileIds(newValues);
|
||||||
|
@ -381,7 +396,10 @@ const UploadPage = () => {
|
||||||
};
|
};
|
||||||
|
|
||||||
const removeCustomIniFile = async (file: UploadFile) => {
|
const removeCustomIniFile = async (file: UploadFile) => {
|
||||||
await removeFileFromStorage(customIniFileId!);
|
if (!await removeFileFromStorage(customIniFileId!)) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
await updateTune(tuneDocumentId!, { customIniFileId: null });
|
await updateTune(tuneDocumentId!, { customIniFileId: null });
|
||||||
setCustomIniFileId(null);
|
setCustomIniFileId(null);
|
||||||
};
|
};
|
||||||
|
|
Loading…
Reference in New Issue