Fixed file overwrite during upload

pull/1779/head
ioedeveloper 3 years ago
parent 960fd05f79
commit 2066213c2e
  1. 2
      libs/remix-ui/workspace/src/lib/actions/workspace.ts
  2. 3
      libs/remix-ui/workspace/src/lib/components/file-explorer.tsx

@ -261,7 +261,7 @@ export const uploadFile = async (target, targetFolder: string, cb?: (err: Error,
fileReader.readAsText(file)
cb && cb(null, true)
}
const name = `${targetFolder}/${file.name}`
const name = targetFolder === '/' ? file.name : `${targetFolder}/${file.name}`
workspaceProvider.exists(name).then(exist => {
if (!exist) {

@ -169,9 +169,10 @@ export const FileExplorer = (props: FileExplorerProps) => {
}
const uploadFile = (target) => {
const parentFolder = getFocusedFolder()
let parentFolder = getFocusedFolder()
const expandPath = [...new Set([...props.expandPath, parentFolder])]
parentFolder = parentFolder === name ? '/' : parentFolder
props.dispatchHandleExpandPath(expandPath)
props.dispatchUploadFile(target, parentFolder)
}

Loading…
Cancel
Save