-
-
Notifications
You must be signed in to change notification settings - Fork 138
Description
Describe the bug
During bulk file uploads via the Nextcloud desktop sync client, PostWriteListener fails with LockedException because the file has an exclusive lock from the upload process, and TimelineWrite::processFile() tries to acquire another exclusive lock.
This results in "Write hook failed to index file" errors for every image uploaded during concurrent sync operations. The files are never indexed in real-time.
Environment
- Memories: 7.8.2
- Nextcloud: 32.0.5
- PHP: 8.x
- DB: MariaDB 11.8
- Sync client: 4.0.6
Steps To Reproduce
Root cause
In TimelineWrite.php:55-67, processFile() acquires LOCK_EXCLUSIVE by default. But during a DAV PUT (upload), the file already has an exclusive lock from Nextcloud core. The lock conflict causes an unhandled LockedException.
Proposed fix - proposal contributed by arkDisk
Catch LockedException in PostWriteListener.php and log at debug level. The file will be picked up by the background cron indexer:
} catch (LockedException $e) {
$this->logger->debug('File locked during upload, deferring to cron', [
'app' => 'memories',
'path' => $node->getPath(),
]);
} catch (\Exception $e) {This is a one-line fix that preserves real-time indexing for single uploads while gracefully handling bulk uploads.