From 664f33a29c81701fbf6a7fb18eda81e1c4665ecc Mon Sep 17 00:00:00 2001
From: Michael Gapczynski <mtgap@owncloud.com>
Date: Sat, 19 Jan 2013 21:04:25 -0500
Subject: [PATCH] Update mtimes of all parent folders after change inside

---
 lib/files/cache/updater.php | 16 +++++++++++-----
 1 file changed, 11 insertions(+), 5 deletions(-)

diff --git a/lib/files/cache/updater.php b/lib/files/cache/updater.php
index 8b0d383503..d04541c219 100644
--- a/lib/files/cache/updater.php
+++ b/lib/files/cache/updater.php
@@ -35,7 +35,7 @@ class Updater {
 			$scanner = $storage->getScanner($internalPath);
 			$scanner->scan($internalPath, Scanner::SCAN_SHALLOW);
 			$cache->correctFolderSize($internalPath);
-			self::eTagUpdate($path);
+			self::correctFolder($path, $storage->filemtime($internalPath));
 		}
 	}
 
@@ -49,11 +49,17 @@ class Updater {
 			$cache = $storage->getCache($internalPath);
 			$cache->remove($internalPath);
 			$cache->correctFolderSize($internalPath);
-			self::eTagUpdate($path);
+			self::correctFolder($path, time());
 		}
 	}
 
-	static public function eTagUpdate($path) {
+	/**
+	* Update the mtime and ETag of all parent folders
+	*
+	* @param string $path
+	* @param string $time
+	*/
+	static public function correctFolder($path, $time) {
 		if ($path !== '' && $path !== '/') {
 			$parent = dirname($path);
 			if ($parent === '.') {
@@ -68,8 +74,8 @@ class Updater {
 				$cache = $storage->getCache();
 				$id = $cache->getId($internalPath);
 				if ($id !== -1) {
-					$cache->update($id, array('etag' => $storage->getETag($internalPath)));
-					self::eTagUpdate($parent);
+					$cache->update($id, array('mtime' => $time, 'etag' => $storage->getETag($internalPath)));
+					self::correctFolder($parent, $time);
 				}
 			}
 		}
-- 
GitLab