diff options
author | Thomas Müller <thomas.mueller@tmit.eu> | 2015-10-29 11:57:00 +0100 |
---|---|---|
committer | Thomas Müller <thomas.mueller@tmit.eu> | 2015-10-29 11:57:00 +0100 |
commit | 530f7229e77d731eead7f1dc74296c62856a345b (patch) | |
tree | cfd16bf0803c7f575c57f116bbab0df9b4374eff /lib/private/files/cache | |
parent | 9ab44f1f00715e3c4c0fe2fb6a25846e6fc7495b (diff) | |
parent | f355d4e51a1b597d4e763a10e3ebadb925b0c779 (diff) | |
download | nextcloud-server-530f7229e77d731eead7f1dc74296c62856a345b.tar.gz nextcloud-server-530f7229e77d731eead7f1dc74296c62856a345b.zip |
Merge pull request #19869 from owncloud/cache-adjustcurrentmtimeonrename
On rename, also refresh storage_mtime of the target file
Diffstat (limited to 'lib/private/files/cache')
-rw-r--r-- | lib/private/files/cache/cache.php | 10 | ||||
-rw-r--r-- | lib/private/files/cache/updater.php | 14 |
2 files changed, 23 insertions, 1 deletions
diff --git a/lib/private/files/cache/cache.php b/lib/private/files/cache/cache.php index f3e22701f40..231dbe37695 100644 --- a/lib/private/files/cache/cache.php +++ b/lib/private/files/cache/cache.php @@ -313,6 +313,14 @@ class Cache { $fields = array( 'path', 'parent', 'name', 'mimetype', 'size', 'mtime', 'storage_mtime', 'encrypted', 'etag', 'permissions'); + + $doNotCopyStorageMTime = false; + if (array_key_exists('mtime', $data) && $data['mtime'] === null) { + // this horrific magic tells it to not copy storage_mtime to mtime + unset($data['mtime']); + $doNotCopyStorageMTime = true; + } + $params = array(); $queryParts = array(); foreach ($data as $name => $value) { @@ -325,7 +333,7 @@ class Cache { $queryParts[] = '`mimepart`'; $value = $this->mimetypeLoader->getId($value); } elseif ($name === 'storage_mtime') { - if (!isset($data['mtime'])) { + if (!$doNotCopyStorageMTime && !isset($data['mtime'])) { $params[] = $value; $queryParts[] = '`mtime`'; } diff --git a/lib/private/files/cache/updater.php b/lib/private/files/cache/updater.php index 4cc5f511565..85dcc8589de 100644 --- a/lib/private/files/cache/updater.php +++ b/lib/private/files/cache/updater.php @@ -194,12 +194,26 @@ class Updater { $targetCache->correctFolderSize($targetInternalPath); $this->correctParentStorageMtime($sourceStorage, $sourceInternalPath); $this->correctParentStorageMtime($targetStorage, $targetInternalPath); + $this->updateStorageMTimeOnly($targetStorage, $targetInternalPath); $this->propagator->addChange($source); $this->propagator->addChange($target); $this->propagator->propagateChanges(); } } + private function updateStorageMTimeOnly($storage, $internalPath) { + $cache = $storage->getCache(); + $fileId = $cache->getId($internalPath); + if ($fileId !== -1) { + $cache->update( + $fileId, [ + 'mtime' => null, // this magic tells it to not overwrite mtime + 'storage_mtime' => $storage->filemtime($internalPath) + ] + ); + } + } + /** * update the storage_mtime of the direct parent in the cache to the mtime from the storage * |