Skip to content

TagSpaces is an offline, open source, document manager with tagging support

fix abort upload of files, error message by trying to upload folders #2181 (#2183)

Stanimir039b29475195
diff --git a/src/main/main.ts b/src/main/main.ts
index 31ae964d0..72a47c4e1 100644
--- a/src/main/main.ts
+++ b/src/main/main.ts
@@ -19,7 +19,7 @@ import {
dialog,
} from 'electron';
// import { autoUpdater } from 'electron-updater';
-import log from 'electron-log';
+//import log from 'electron-log';
import pm2 from '@elife/pm2';
import propertiesReader from 'properties-reader';
import { resolveHtmlPath } from './util';
@@ -63,6 +63,10 @@ const isDebug =
if (isDebug) {
require('electron-debug')({ showDevTools: false });
+ if (isMacLike) {
+ // temp fix https://github.com/electron/electron/issues/43415#issuecomment-2359194469
+ app.disableHardwareAcceleration();
+ }
}
const testMode = process.env.NODE_ENV === 'test';
diff --git a/src/renderer/components/dialogs/FileUploadDialog.tsx b/src/renderer/components/dialogs/FileUploadDialog.tsx
index b521b2ddd..9abc17778 100644
--- a/src/renderer/components/dialogs/FileUploadDialog.tsx
+++ b/src/renderer/components/dialogs/FileUploadDialog.tsx
@@ -94,7 +94,15 @@ function FileUploadDialog(props: Props) {
const stopAll = () => {
if (progress) {
- return uploadAbort();
+ if (currentLocation.haveObjectStoreSupport()) {
+ const progresses = progress.map((fileProgress) => {
+ fileProgress.abort();
+ return { ...fileProgress, state: 'finished' };
+ });
+ dispatch(AppActions.setProgresses(progresses));
+ } else {
+ return uploadAbort();
+ }
}
};
@@ -188,7 +196,11 @@ function FileUploadDialog(props: Props) {
const { path, filePath } = fileProgress;
targetPath.current = path.split('?')[0];
let { abort } = fileProgress;
- if (percentage > -1 && percentage < 100) {
+ if (
+ percentage > -1 &&
+ percentage < 100 &&
+ fileProgress.state !== 'finished'
+ ) {
haveProgress = true;
} /*else {
abort = undefined;
diff --git a/src/renderer/hooks/IOActionsContextProvider.tsx b/src/renderer/hooks/IOActionsContextProvider.tsx
index 3eb8b8755..eb30858dc 100644
--- a/src/renderer/hooks/IOActionsContextProvider.tsx
+++ b/src/renderer/hooks/IOActionsContextProvider.tsx
@@ -1186,6 +1186,17 @@ export const IOActionsContextProvider = ({
),
)
.catch((err) => {
+ if (
+ err &&
+ err.message &&
+ err.message.indexOf(
+ 'Error: EISDIR: illegal operation on a directory, read',
+ ) > -1
+ ) {
+ const errorMessage = t('core:uploadDirsNotSupported');
+ showNotification(errorMessage, 'warning', true);
+ dispatch(AppActions.setProgress(filePath, -1, errorMessage));
+ }
// console.log('Error getting file:' + job[0] + ' ' + err);
if (fileType === 'thumb' && job[3]) {
return generateThumbnailPromise(
diff --git a/src/renderer/locales/en/core.json b/src/renderer/locales/en/core.json
index 2e65c032d..d6f4092ee 100644
--- a/src/renderer/locales/en/core.json
+++ b/src/renderer/locales/en/core.json
@@ -868,5 +868,6 @@
"newFromDownloadURL": "New From URL",
"invalidSharingLink": "Invalid Sharing Link",
"confirmSearchById": "Do you want to search for the file or folder by its ID?",
+ "uploadDirsNotSupported": "Uploading folders not supported!",
"-": "-"
}
diff --git a/src/renderer/reducers/app.ts b/src/renderer/reducers/app.ts
index 88e82d2c9..3cae5421e 100644
--- a/src/renderer/reducers/app.ts
+++ b/src/renderer/reducers/app.ts
@@ -127,6 +127,7 @@ export default (state: any = initialState, action: any) => {
filePath: action.filePath,
progress: action.progress,
abort: action.abort,
+ state: 'started',
},
];
state.progress.map((fileProgress) => {
@@ -138,7 +139,7 @@ export default (state: any = initialState, action: any) => {
return { ...state, progress: arrProgress };
}
case types.PROGRESS_FINISH: {
- return { ...state, progress: action.progresses };
+ return { ...state, progress: action.progresses, state: 'finished' };
}
case types.RESET_PROGRESS: {
return { ...state, progress: [] };