Skip to content

fix(dav): skip quota check when moving file within the same storage - #65484

Open
DarelShroo wants to merge 5 commits into
nextcloud:masterfrom
DarelShroo:fix/dav-quota-same-storage-move
Open

DarelShroo wants to merge 5 commits into
nextcloud:masterfrom
DarelShroo:fix/dav-quota-same-storage-move

Conversation

@DarelShroo

Copy link
Copy Markdown

Signed-off-by: Darel Martínez Caballero darelmartinezcaballero@gmail.com

Summary

When moving or renaming files inside the same storage backend (local disk, NFS, or external storage mounts), the net disk space consumed on that storage is zero (an atomic filesystem rename() / inode update).
Previously, QuotaPlugin::beforeMove() unconditionally validated whether the destination path had available free space greater than or equal to the entire source file size ($this->checkQuota($quotaPath, $sourceNode->getSize())).
On storages with low remaining free space (e.g., 10 GB free on disk) where a user attempts to move or rename a large file (e.g., a 16 GB file) within the same mount or folder structure, Nextcloud aborted the operation throwing a false-positive HTTP 507 InsufficientStorage exception.

Solution

In QuotaPlugin::beforeMove(), we retrieve the storage instances of both the source node and the destination parent path:

  • $sourceStorage = $sourceNode->getFileInfo()?->getStorage();
  • $destStorage = $destInfo?->getStorage();
    If $sourceStorage->getId() === $destStorage->getId(), both source and destination resolve to the identical storage backend instance. The net space consumption is zero, so the redundant free-space check is safely bypassed. If the storage cannot be determined or source and destination belong to different storages, it cleanly falls back to the existing checkQuota() validation.

Checklist

AI (if applicable)

  • The contribution was developed, reviewed, tested, and validated by the human author.
  • Author: Darel Martínez Caballero
  • The patch was tested and validated on a live Nextcloud production instance, resolving the WebDAV 507 InsufficientStorage exception during large file moves.
  • Unit tests were added to apps/dav/tests/unit/Connector/Sabre/QuotaPluginTest.php.

Signed-off-by: Darel Martínez Caballero <darelmartinezcaballero@gmail.com>
@DarelShroo
DarelShroo requested a review from a team as a code owner October 13, 2026 20:09
@DarelShroo
DarelShroo requested review from icewind1991, leftybournes, salmart-dev and sorbaugh and removed request for a team October 13, 2026 20:09

This branch has not been deployed

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

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant