apache/dolphinscheduler · error · FileAlreadyExistsException

Directory already exists: ${directoryAbsolutePath}

Error message

Directory already exists: ${directoryAbsolutePath}

What it means

A sentinel guard in the local-storage operator's createStorageDir: Files.exists on the target directory returned true, so creation is refused instead of overwriting. The offending input is directoryAbsolutePath — it fires on repeated uploads or re-creation of an already-present resource directory on local disk; it is not a filesystem error.

Source

Thrown at dolphinscheduler-storage-plugin/dolphinscheduler-storage-api/src/main/java/org/apache/dolphinscheduler/plugin/storage/api/local/LocalStorageOperator.java:69

    public LocalStorageOperator(String resourceBaseAbsolutePath) throws IOException {
        super(resourceBaseAbsolutePath);
        final Path path = Paths.get(resourceBaseAbsolutePath);
        if (Files.exists(path)) {
            if (!Files.isDirectory(path)) {
                throw new IllegalArgumentException("The base path must be a directory: " + resourceBaseAbsolutePath);
            }
        } else {
            Files.createDirectories(path);
        }
    }

    @SneakyThrows
    @Override
    public void createStorageDir(String directoryAbsolutePath) {
        final Path path = Paths.get(directoryAbsolutePath);
        if (exists(directoryAbsolutePath)) {
            throw new FileAlreadyExistsException("Directory already exists: " + directoryAbsolutePath);
        }
        Files.createDirectories(path);
    }

    @Override
    public boolean exists(String resourceAbsolutePath) {
        return Files.exists(Paths.get(resourceAbsolutePath));
    }

    @SneakyThrows
    @Override
    public void delete(String resourceAbsolutePath, boolean recursive) {
        if (recursive) {
            FileUtils.deleteQuietly(new File(resourceAbsolutePath));
        } else {
            Files.deleteIfExists(Paths.get(resourceAbsolutePath));
        }
    }

View on GitHub (pinned to 02eac45a1b)

Solutions

  1. Check existence before calling createStorageDir and treat existing directories as success
  2. Delete the existing local directory (via delete with recursive=true) when a clean re-create is needed
  3. Make directory creation idempotent by using Files.createDirectories semantics
Defensive patterns

Strategy: validation

When it happens

Trigger: Thrown at dolphinscheduler-storage-plugin/dolphinscheduler-storage-api/src/main/java/org/apache/dolphinscheduler/plugin/storage/api/local/LocalStorageOperator.java:69 when the library encounters an invalid state.

Common situations: See trigger scenarios.


AI-assisted analysis of apache/dolphinscheduler@02eac45a1b (2026-09-06). Data as JSON: /api/errors/20f889c148e08126. Report an issue: GitHub.