Skip to content
Snippets Groups Projects
Commit 53e51fe4 authored by Bart Visscher's avatar Bart Visscher
Browse files

Clean user cache on login

parent 8a02a885
No related branches found
No related tags found
No related merge requests found
......@@ -346,8 +346,9 @@ class OC{
}
}
// register cache cleanup
// register cache cleanup jobs
OC_BackgroundJob_RegularTask::register('OC_Cache_FileGlobal', 'gc');
OC_Hook::connect('OC_User', 'post_login', 'OC_Cache_File', 'loginListener');
// Check for blacklisted files
OC_Hook::connect('OC_Filesystem','write','OC_Filesystem','isBlacklisted');
......
......@@ -74,4 +74,25 @@ class OC_Cache_File{
}
return true;
}
public function gc() {
$storage = $this->getStorage();
if($storage and $storage->is_dir('/')) {
$now = time();
$dh=$storage->opendir('/');
while($file=readdir($dh)) {
if($file!='.' and $file!='..') {
$mtime = $storage->filemtime('/'.$file);
if ($mtime < $now) {
$storage->unlink('/'.$file);
}
}
}
}
}
public static function loginListener() {
$c = new self();
$c->gc();
}
}
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment