summaryrefslogtreecommitdiffstats
path: root/lib
diff options
context:
space:
mode:
authorVincent Petry <pvince81@owncloud.com>2015-10-16 18:28:45 +0200
committerVincent Petry <pvince81@owncloud.com>2015-10-26 15:41:23 +0100
commitb900782513a750e5e100c7d55278632754a8df19 (patch)
tree2924f23ebc0325d8e83528079a768855e64584ff /lib
parentcbd31e4fa9e7d4e469f2f3fc955e9b8e76f8628e (diff)
downloadnextcloud-server-b900782513a750e5e100c7d55278632754a8df19.tar.gz
nextcloud-server-b900782513a750e5e100c7d55278632754a8df19.zip
Also adjust storage_mtime of target after rename
Some storages like Dropbox change their mtime on rename...
Diffstat (limited to 'lib')
-rw-r--r--lib/private/files/cache/cache.php10
-rw-r--r--lib/private/files/cache/updater.php14
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 2de0c8fe067..c82ee33a1b1 100644
--- a/lib/private/files/cache/updater.php
+++ b/lib/private/files/cache/updater.php
@@ -193,12 +193,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
*