Skip to content

Automatically create missing parent directories for filesystem write operations #57875

@marinofaggiana

Description

@marinofaggiana

Context

Currently, several filesystem write operations in Nextcloud require clients to manually verify and/or create parent directories before performing the actual operation.

This applies in particular to:
• file uploads (PUT)
• MOVE operations
• directory creation (MKCOL)

Clients are therefore forced to:
• perform additional PROPFIND / MKCOL calls
• re-implement filesystem logic already known by the server
• handle race conditions when directories are created concurrently

This proposal moves this responsibility to the server.

What does

This proposal ensures that all filesystem write operations automatically create missing parent directories, recursively, when needed.

The behavior applies to:
• file uploads (PUT)
• MOVE operations
• directory creation (MKCOL)

If a target path includes one or more non-existing parent directories, the server will:
• create the full directory chain automatically
• proceed with the requested operation
• behave idempotently if directories already exist

Examples

Upload (PUT)
Uploading to: /files/user/Photos/2025/01/image.jpg
will automatically create:
Photos/
Photos/2025/
Photos/2025/01/

MOVE
Moving a file to: /files/user/Archive/2024/Reports/file.pdf
will automatically create all missing parent directories before executing the MOVE.

MKCOL
Creating a directory at: /files/user/Projects/Nextcloud/iOS
will automatically create:
Projects/
Projects/Nextcloud/
Projects/Nextcloud/iOS/
even if intermediate directories do not exist.

Why this matters

•	Eliminates redundant client-side directory checks
•	Prevents race conditions between concurrent clients
•	Reduces network round-trips
•	Aligns Nextcloud behavior with modern object-storage semantics
•	Simplifies client implementations (mobile, desktop, WebDAV clients)

Scope & compatibility
• No API changes
• No client behavior regression
• Existing clients continue to work unchanged
• New behavior is additive and backward compatible

Metadata

Metadata

Assignees

No one assigned

    Labels

    0. Needs triagePending check for reproducibility or if it fits our roadmapenhancement

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions