]> source.dussan.org Git - nextcloud-server.git/commitdiff
clear the filecache if the mount configuration has changed
authorRobin Appelman <icewind@owncloud.com>
Thu, 6 Sep 2012 21:10:24 +0000 (23:10 +0200)
committerRobin Appelman <icewind@owncloud.com>
Thu, 6 Sep 2012 21:10:33 +0000 (23:10 +0200)
lib/filecache.php
lib/filesystem.php

index 811e8a3e6a2efb3c5654d685331fb2cd709cc321..de38ad99e8e11ccce9a1d4ae2b23cded0816c1d6 100644 (file)
@@ -474,6 +474,20 @@ class OC_FileCache{
                $query=OC_DB::prepare('DELETE FROM `*PREFIX*fscache` WHERE LENGTH(`path_hash`)<30');
                $query->execute();
        }
+
+       /**
+        * clear filecache entries
+        * @param string user (optonal)
+        */
+       public static function clear($user=''){
+               if($user){
+                       $query=OC_DB::prepare('DELETE FROM `*PREFIX*fscache` WHERE user=?');
+                       $query->execute(array($user));
+               }else{
+                       $query=OC_DB::prepare('DELETE FROM `*PREFIX*fscache`');
+                       $query->execute();
+               }
+       }
 }
 
 //watch for changes and try to keep the cache up to date
index c69970467f588996b6923fbf7a3c934bb2853166..01467b54c8d8ffe4432f3717f8409a308b44f17c 100644 (file)
@@ -236,6 +236,13 @@ class OC_Filesystem{
                                        }
                                }
                        }
+
+                       $mtime=filemtime(OC::$SERVERROOT.'/config/mount.php');
+                       $previousMTime=OC_Appconfig::getValue('files','mountconfigmtime',0);
+                       if($mtime>$previousMTime){//mount config has changed, filecache needs to be updated
+                               OC_FileCache::clear();
+                               OC_Appconfig::setValue('files','mountconfigmtime',$mtime);
+                       }
                }
 
                self::$loaded=true;