Skip to content

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

fix copy move files

sytolka65f3a2cfa9d
diff --git a/src/renderer/components/TargetFileBox.tsx b/src/renderer/components/TargetFileBox.tsx
index 7b4c8ad49..37351dc6b 100644
--- a/src/renderer/components/TargetFileBox.tsx
+++ b/src/renderer/components/TargetFileBox.tsx
@@ -33,6 +33,7 @@ import React, { ReactNode } from 'react';
import { DropTargetMonitor, useDrop } from 'react-dnd';
import { useTranslation } from 'react-i18next';
import { useDispatch } from 'react-redux';
+import { CommonLocation } from '-/utils/CommonLocation';
type DragItem = { files: File[]; items: DataTransferItemList };
type DragProps = {
@@ -53,8 +54,7 @@ function TargetFileBox(props: Props) {
const theme = useTheme();
const dispatch: AppDispatch = useDispatch();
const { openFileUploadDialog } = useFileUploadDialogContext();
- const { currentLocation, findLocalLocation, findLocation } =
- useCurrentLocationContext();
+ const { findLocalLocation, findLocation } = useCurrentLocationContext();
const { setMetaUpload } = useFileUploadContext();
const { uploadFilesAPI, uploadMeta } = useIOActionsContext();
const { showNotification } = useNotificationContext();
@@ -69,8 +69,11 @@ function TargetFileBox(props: Props) {
dispatch(AppActions.onUploadProgress(progress, abort, fileName));
};
- const handleCopyFiles = (files: Array<File>) => {
- if (currentLocation?.isReadOnly) {
+ const handleCopyFiles = (
+ files: Array<File>,
+ targetLocation: CommonLocation,
+ ) => {
+ if (targetLocation?.isReadOnly) {
showNotification(t('core:dndDisabledReadOnlyMode'), 'error', true);
return Promise.reject(t('core:dndDisabledReadOnlyMode'));
}
@@ -98,7 +101,7 @@ function TargetFileBox(props: Props) {
onUploadProgress,
false,
false,
- undefined,
+ targetLocation.uuid,
sourceLocationId,
)
.then((fsEntries: Array<TS.FileSystemEntry>) => {
@@ -108,7 +111,7 @@ function TargetFileBox(props: Props) {
dirPath,
onUploadProgress,
false,
- undefined,
+ targetLocation.uuid,
sourceLocationId,
),
);
@@ -144,15 +147,19 @@ function TargetFileBox(props: Props) {
return file;
});
}
- const location = findLocation(locationId);
+ const targetLocation = findLocation(locationId);
if (
AppConfig.isElectron &&
- !location.haveObjectStoreSupport() &&
- !location.haveWebDavSupport()
+ !targetLocation.haveObjectStoreSupport() &&
+ !targetLocation.haveWebDavSupport()
) {
- return openMoveOrCopyFilesDialog(files, dirPath, location.uuid);
+ return openMoveOrCopyFilesDialog(
+ files,
+ dirPath,
+ targetLocation.uuid,
+ );
} else {
- return handleCopyFiles(files);
+ return handleCopyFiles(files, targetLocation);
}
}
},
diff --git a/src/renderer/hooks/IOActionsContextProvider.tsx b/src/renderer/hooks/IOActionsContextProvider.tsx
index fbbb1dd6d..2935af2be 100644
--- a/src/renderer/hooks/IOActionsContextProvider.tsx
+++ b/src/renderer/hooks/IOActionsContextProvider.tsx
@@ -1188,7 +1188,11 @@ export const IOActionsContextProvider = ({
// handle meta files
if (fileType === 'meta') {
try {
- fsEntry.meta = loadJSONString(fileContent.toString());
+ const data =
+ fileContent instanceof Uint8Array
+ ? new TextDecoder('utf-8')
+ : fileContent.toString();
+ fsEntry.meta = loadJSONString(data);
} catch (e) {
console.debug('cannot parse entry meta');
}