From 3ab1bd45491da09d7bf44a4016c4bb480adcc591 Mon Sep 17 00:00:00 2001 From: Josh Date: Sun, 17 May 2026 10:44:58 -0400 Subject: [PATCH] fix(dav): preserves the old hook-accessibility contract while still improving consistency Signed-off-by: Josh --- apps/dav/lib/Connector/Sabre/File.php | 16 +++++++++------- 1 file changed, 9 insertions(+), 7 deletions(-) diff --git a/apps/dav/lib/Connector/Sabre/File.php b/apps/dav/lib/Connector/Sabre/File.php index ca6d56b7d53..40afe0f2f25 100644 --- a/apps/dav/lib/Connector/Sabre/File.php +++ b/apps/dav/lib/Connector/Sabre/File.php @@ -345,8 +345,9 @@ class File extends Node implements IFile { private function finalizeUpload(IStorage $storage, string $internalPath, bool $exists, ?View $view): void { // Since we skipped the view for the final publish step, finalize the file - // state explicitly here: update cache/bookkeeping, persist metadata, emit - // post-write hooks, and only then downgrade the lock. + // state explicitly here: update cache/bookkeeping, persist metadata, then + // downgrade to a shared lock before emitting post-write hooks so listeners + // can still access the file. $storage->getUpdater()->update($internalPath); $fileInfoUpdate = [ @@ -381,16 +382,17 @@ class File extends Node implements IFile { $this->fileView->putFileInfo($this->path, $fileInfoUpdate); $this->refreshInfo(); - if ($view) { - $this->emitPostHooks($exists); - } - - // Keep the exclusive lock until all bookkeeping and metadata updates are complete. + // Downgrade to shared lock before post hooks so legacy hook consumers can + // still access the file during post_write. try { $this->changeLock(ILockingProvider::LOCK_SHARED); } catch (LockedException $e) { throw new FileLocked($e->getMessage(), $e->getCode(), $e); } + + if ($view) { + $this->emitPostHooks($exists); + } } private function getPartFileBasePath($path) {