update the filecache by setting mtimes to 0 when the mount configuration has changed instead of clearing the cache

remotes/origin/stable45
Robin Appelman 12 years ago
parent 113c339c41
commit 91d12a2f3d
  1. 14
      lib/filecache.php
  2. 4
      lib/filesystem.php
  3. 4
      lib/util.php

@ -488,6 +488,20 @@ class OC_FileCache{
$query->execute();
}
}
/**
* trigger an update for the cache by setting the mtimes to 0
* @param string $user (optional)
*/
public static function triggerUpdate($user=''){
if($user) {
$query=OC_DB::prepare('UPDATE `*PREFIX*fscache` SET `mtime`=0 WHERE `user`=? AND `mimetype`="httpd/unix-directory"');
$query->execute(array($user));
}else{
$query=OC_DB::prepare('UPDATE `*PREFIX*fscache` SET `mtime`=0 AND `mimetype`="httpd/unix-directory"');
$query->execute();
}
}
}
//watch for changes and try to keep the cache up to date

@ -240,7 +240,7 @@ 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_FileCache::triggerUpdate();
OC_Appconfig::setValue('files','mountconfigmtime',$mtime);
}
}
@ -531,7 +531,7 @@ class OC_Filesystem{
if ($root) { // reduce path to the required part of it (no 'username/files')
$fakeRootView = new OC_FilesystemView($root);
$count = 1;
$path=str_replace(OC_App::getStorage("files")->getAbsolutePath(), "", $fakeRootView->getAbsolutePath($path), $count);
$path=str_replace(OC_App::getStorage("files")->getAbsolutePath($path), "", $fakeRootView->getAbsolutePath($path), $count);
}
$path = self::normalizePath($path);

@ -62,7 +62,7 @@ class OC_Util {
$mtime=filemtime($user_root.'/mount.php');
$previousMTime=OC_Preferences::getValue($user,'files','mountconfigmtime',0);
if($mtime>$previousMTime) {//mount config has changed, filecache needs to be updated
OC_FileCache::clear($user);
OC_FileCache::triggerUpdate($user);
OC_Preferences::setValue($user,'files','mountconfigmtime',$mtime);
}
}
@ -574,4 +574,4 @@ class OC_Util {
}
return $pseudo_byte;
}
}
}

Loading…
Cancel
Save