Skip to content

Commit f499ea0

Browse files
committed
fix: React to 'postScanFile' events to properly manage transaction TTL
Signed-off-by: Louis Chmn <louis@chmn.me>
1 parent 492fd79 commit f499ea0

File tree

1 file changed

+13
-3
lines changed

1 file changed

+13
-3
lines changed

lib/private/Files/Utils/Scanner.php

Lines changed: 13 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -237,6 +237,12 @@ public function scan(string $dir = '', $recursive = \OC\Files\Cache\Scanner::SCA
237237
$this->eventDispatcher->dispatchTyped(new NodeAddedToCache($storage, $path));
238238
}
239239
});
240+
$scanner->listen('\OC\Files\Cache\Scanner', 'postScanFile', function ($file, $storageId) use ($storage): void {
241+
$this->postProcessEntry($storage);
242+
});
243+
$scanner->listen('\OC\Files\Cache\Scanner', 'postScanFolder', function ($path, $storageId) use ($storage): void {
244+
$this->postProcessEntry($storage);
245+
});
240246

241247
if (!$storage->file_exists($relativePath)) {
242248
throw new NotFoundException($dir);
@@ -278,10 +284,14 @@ private function triggerPropagator(IStorage $storage, $internalPath) {
278284
$storage->getPropagator()->propagateChange($internalPath, time());
279285
}
280286

281-
private function postProcessEntry(IStorage $storage, $internalPath) {
282-
$this->triggerPropagator($storage, $internalPath);
287+
private function postProcessEntry(IStorage $storage, ?string $internalPath = null): void {
288+
if ($internalPath !== null) {
289+
$this->triggerPropagator($storage, $internalPath);
290+
}
283291
if ($this->useTransaction) {
284-
$this->entriesToCommit++;
292+
if ($internalPath !== null) {
293+
$this->entriesToCommit++;
294+
}
285295
if ($this->entriesToCommit >= self::MAX_ENTRIES_TO_COMMIT
286296
|| $this->transactionStartTime + self::TRANSACTION_SECOND_TIMEOUT <= $this->timeFactory->getTime()
287297
) {

0 commit comments

Comments
 (0)