Skip to content

Enhancement Request: allowOverwrite option + confirmation for duplicate uploads #247

Description

@ewrayjohnson

Summary
The upload UI currently blocks duplicate filenames client‑side, preventing server‑side overwrite workflows (e.g., versioning systems, audit trails, WebDAV). Add a configuration option to allow duplicates with user confirmation, while defaulting to the current blocking behavior when the option is not set.

Current behavior (blocking)
In frontend/src/FileManager/Actions/UploadFile/UploadFile.action.jsx , the checkFileError function rejects duplicate filenames::

const fileExists = currentPathFiles.some(
  (item) => item.name.toLowerCase() === file.name.toLowerCase() && !item.isDirectory
);
if (fileExists) return t("fileAlreadyExist");

Result: User cannot upload a file with the same name as an existing file, even if the backend supports overwrite.

Requested behavior
Add a config flag to fileUploadConfig:

<FileManager
  ...
  fileUploadConfig={{ allowOverwrite: true }}
/>

Logic:

  1. Default behavior remains unchanged (duplicates are blocked)
  2. If allowOverwrite is true:
    -- show a confirmation prompt when duplicate name is detected
    -- if user confirms → proceed with upload
    -- if user cancels → abort upload

Pseudo‑code:

if (fileExists) {
  if (!_allowOverwrite_) return t("fileAlreadyExist");
  const confirmed = window.confirm(t("confirmOverwrite"));
  if (!confirmed) return t("uploadCanceled");
}

Rationale
Backends with versioned storage, audit trails, or WebDAV require overwrites to be handled server‑side:

  • Example: REST API with overwrite=true header creates UPDATE audit entries (not DELETE + CREATE)
  • Example: WebDAV PUT operations with precondition headers manage versions
  • Current limitation: Client blocks the upload before server can decide
    This enhancement allows backends to implement proper versioning while maintaining safe defaults for traditional file managers.

Acceptance criteria

  • No config provided → identical behavior to today (blocks duplicates)
  • allowOverwrite: true → duplicate filename triggers confirmation dialog
  • User confirms → upload proceeds normally
  • User cancels → upload aborted (no error message, just silent cancellation)
  • Existing code paths unaffected
  • Tests updated for both code paths

i18n additions

{
  "confirmOverwrite": "A file with this name already exists. Do you want to replace it?",
  "uploadCanceled": "Upload canceled."
}

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions