@@ -345,8 +345,9 @@ public function put($data) {
345345
346346 private function finalizeUpload (IStorage $ storage , string $ internalPath , bool $ exists , ?View $ view ): void {
347347 // Since we skipped the view for the final publish step, finalize the file
348- // state explicitly here: update cache/bookkeeping, persist metadata, emit
349- // post-write hooks, and only then downgrade the lock.
348+ // state explicitly here: update cache/bookkeeping, persist metadata, then
349+ // downgrade to a shared lock before emitting post-write hooks so listeners
350+ // can still access the file.
350351 $ storage ->getUpdater ()->update ($ internalPath );
351352
352353 $ fileInfoUpdate = [
@@ -381,16 +382,17 @@ private function finalizeUpload(IStorage $storage, string $internalPath, bool $e
381382 $ this ->fileView ->putFileInfo ($ this ->path , $ fileInfoUpdate );
382383 $ this ->refreshInfo ();
383384
384- if ($ view ) {
385- $ this ->emitPostHooks ($ exists );
386- }
387-
388- // Keep the exclusive lock until all bookkeeping and metadata updates are complete.
385+ // Downgrade to shared lock before post hooks so legacy hook consumers can
386+ // still access the file during post_write.
389387 try {
390388 $ this ->changeLock (ILockingProvider::LOCK_SHARED );
391389 } catch (LockedException $ e ) {
392390 throw new FileLocked ($ e ->getMessage (), $ e ->getCode (), $ e );
393391 }
392+
393+ if ($ view ) {
394+ $ this ->emitPostHooks ($ exists );
395+ }
394396 }
395397
396398 private function getPartFileBasePath ($ path ) {
0 commit comments