Skip to content

Commit d050233

Browse files
committed
debug: Try to fix tests
Signed-off-by: Louis Chemineau <louis@chmn.me>
1 parent 6a0e117 commit d050233

1 file changed

Lines changed: 10 additions & 2 deletions

File tree

lib/private/Files/Cache/Updater.php

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -200,11 +200,19 @@ private function copyOrRenameFromStorage(IStorage $sourceStorage, string $source
200200
$sourceInfo = $sourceCache->get($source);
201201

202202
if ($sourceInfo !== false) {
203+
// Remove existing cache entry to no reuse the fileId.
203204
if ($this->cache->inCache($target)) {
204-
$this->cache->remove($target);
205+
$existingCacheInfo = $this->cache->get($target);
206+
// Do not remove the existing target if it has just been created.
207+
// It was probably created by the same operation and we want to keep the fileId.
208+
if (time() - $existingCacheInfo->getMTime() > 1) {
209+
$this->cache->remove($target);
210+
}
205211
}
206212

207-
$operation($sourceCache, $sourceInfo);
213+
if (!$this->cache->inCache($target)) {
214+
$operation($sourceCache, $sourceInfo);
215+
}
208216

209217
$sourceExtension = pathinfo($source, PATHINFO_EXTENSION);
210218
$targetExtension = pathinfo($target, PATHINFO_EXTENSION);

0 commit comments

Comments
 (0)