add export directory exists checks

This commit is contained in:
Abhinav 2023-03-02 13:57:43 +05:30
parent 60fcf46c63
commit eabcc72b61
2 changed files with 9 additions and 0 deletions

View file

@ -375,6 +375,13 @@ class ExportService {
if (!folder) {
folder = getData(LS_KEYS.EXPORT)?.folder;
}
if (!folder) {
throw Error(CustomError.NO_EXPORT_FOLDER_SELECTED);
}
const exportFolderExists = this.exists(folder);
if (!exportFolderExists) {
throw Error(CustomError.EXPORT_FOLDER_DOES_NOT_EXIST);
}
const recordFile = await this.electronAPIs.getExportRecord(
`${folder}/${EXPORT_RECORD_FILE_NAME}`
);

View file

@ -56,6 +56,8 @@ export const CustomError = {
NETWORK_ERROR: 'Network Error',
NOT_FILE_OWNER: 'not file owner',
ADD_FILE_EXPORTED_RECORD_FAILED: 'add file exported record failed',
NO_EXPORT_FOLDER_SELECTED: 'no export folder selected',
EXPORT_FOLDER_DOES_NOT_EXIST: 'export folder does not exist',
};
export function parseUploadErrorCodes(error) {