Skip to content

Commit

Permalink
Don't nest uploaded projects
Browse files Browse the repository at this point in the history
  • Loading branch information
fruttasecca committed May 9, 2022
1 parent 02de078 commit 69d496d
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 2 deletions.
12 changes: 10 additions & 2 deletions services/orchest-webserver/client/src/components/DropZone.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -28,11 +28,13 @@ export const generateUploadFiles = ({
projectUuid,
root,
path: targetFolderPath,
isProjectUpload,
cancelableFetch,
}: {
projectUuid?: string;
root: FileManagementRoot;
path: string;
isProjectUpload?: boolean;
cancelableFetch?: Fetcher<void>;
}) => (
files: File[] | FileList,
Expand All @@ -49,7 +51,7 @@ export const generateUploadFiles = ({
: file.webkitRelativePath !== undefined &&
file.webkitRelativePath.includes("/");

const path = !isUploadedAsFolder
let path = !isUploadedAsFolder
? targetFolderPath
: `${targetFolderPath}${(isUploadedViaDropzone(file)
? file.path
Expand All @@ -58,7 +60,13 @@ export const generateUploadFiles = ({
.split("/")
.slice(0, -1)
.filter((value) => value.length > 0)
.join("/")}/`;
// Do not nest the project directory content.
.slice(isProjectUpload ? 1 : 0)
.join("/")}`;

if (isUploadedAsFolder && !path.endsWith("/")) {
path = path + "/";
}

let formData = new FormData();
formData.append("file", file);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -160,6 +160,7 @@ export function FileManager() {
projectUuid,
root,
path: lastSelectedFolder,
isProjectUpload: false,
})(files, onUploaded)
);
},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -432,6 +432,7 @@ export const ImportDialog: React.FC<{
projectUuid: undefined,
root: "/data",
path: `/${projectName}/`,
isProjectUpload: true,
// Use cancelable fetch to prevent mutating states when user cancel uploading.
cancelableFetch,
})(files, onFileUploaded)
Expand Down

0 comments on commit 69d496d

Please sign in to comment.