Skip to content

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

fix Creating files in S3 location without path not possible

sytolk87b91d64162a
diff --git a/src/renderer/components/dialogs/components/CreateFile.tsx b/src/renderer/components/dialogs/components/CreateFile.tsx
index 7c805e12c..c7c2492db 100644
--- a/src/renderer/components/dialogs/components/CreateFile.tsx
+++ b/src/renderer/components/dialogs/components/CreateFile.tsx
@@ -23,7 +23,10 @@ import Button from '@mui/material/Button';
import ButtonGroup from '@mui/material/ButtonGroup';
import Typography from '@mui/material/Typography';
import Grid from '@mui/material/Grid';
-import { formatDateTime4Tag } from '@tagspaces/tagspaces-common/misc';
+import {
+ formatDateTime4Tag,
+ locationType,
+} from '@tagspaces/tagspaces-common/misc';
import AppConfig from '-/AppConfig';
import { getFirstRWLocation } from '-/reducers/locations';
import Tooltip from '-/components/Tooltip';
@@ -61,7 +64,7 @@ function CreateFile(props: Props) {
const { t } = useTranslation();
//const dispatch: AppDispatch = useDispatch();
- const { openLocation } = useCurrentLocationContext();
+ const { currentLocation, openLocation } = useCurrentLocationContext();
const { currentDirectoryPath } = useDirectoryContentContext();
const { targetDirectoryPath } = useTargetPathContext();
@@ -89,7 +92,10 @@ function CreateFile(props: Props) {
}
function loadLocation() {
- if (!currentDirectoryPath && firstRWLocation) {
+ const isCloudLocation =
+ currentLocation && currentLocation.type === locationType.TYPE_CLOUD;
+ // no currentDirectoryPath in root cloud location
+ if (!isCloudLocation && !currentDirectoryPath && firstRWLocation) {
openLocation(firstRWLocation);
}
}
diff --git a/src/renderer/components/dialogs/hooks/TargetPathContextProvider.tsx b/src/renderer/components/dialogs/hooks/TargetPathContextProvider.tsx
index a15ae1f6d..8e35b5ecc 100644
--- a/src/renderer/components/dialogs/hooks/TargetPathContextProvider.tsx
+++ b/src/renderer/components/dialogs/hooks/TargetPathContextProvider.tsx
@@ -18,10 +18,12 @@
import React, { createContext, useMemo } from 'react';
import { useSelector } from 'react-redux';
+import { locationType } from '@tagspaces/tagspaces-common/misc';
import { getFirstRWLocation } from '-/reducers/locations';
import { PerspectiveIDs } from '-/perspectives';
import { useDirectoryContentContext } from '-/hooks/useDirectoryContentContext';
import { useSelectedEntriesContext } from '-/hooks/useSelectedEntriesContext';
+import { useCurrentLocationContext } from '-/hooks/useCurrentLocationContext';
type TargetPathContextData = {
targetDirectoryPath: string;
@@ -38,6 +40,7 @@ export type TargetPathContextProviderProps = {
export const TargetPathContextProvider = ({
children,
}: TargetPathContextProviderProps) => {
+ const { currentLocation } = useCurrentLocationContext();
const { selectedEntries } = useSelectedEntriesContext();
const { currentDirectoryPerspective, currentDirectoryPath } =
useDirectoryContentContext();
@@ -55,8 +58,14 @@ export const TargetPathContextProvider = ({
targetDirectoryPath = selectedEntries[0].path;
}
- if (!targetDirectoryPath && firstRWLocation) {
- targetDirectoryPath = firstRWLocation.path;
+ if (!targetDirectoryPath) {
+ const isCloudLocation =
+ currentLocation && currentLocation.type === locationType.TYPE_CLOUD;
+ if (isCloudLocation) {
+ targetDirectoryPath = '/';
+ } else if (firstRWLocation) {
+ targetDirectoryPath = firstRWLocation.path;
+ }
}
return {
targetDirectoryPath,