Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/nextcloud/server.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBart Visscher <bartv@thisnet.nl>2012-08-29 01:07:09 +0400
committerBart Visscher <bartv@thisnet.nl>2012-08-29 01:07:28 +0400
commit53e51fe46b3a78b117bd43de922c0fea67d49670 (patch)
treefb76912fcb6a1c4f9ead21aa19919badc06cc522
parent8a02a8852fc912398b5348b8e3263cd4048d5b1b (diff)
Clean user cache on login
-rw-r--r--lib/base.php3
-rw-r--r--lib/cache/file.php21
2 files changed, 23 insertions, 1 deletions
diff --git a/lib/base.php b/lib/base.php
index af860027c1d..d3f3c5ba1c6 100644
--- a/lib/base.php
+++ b/lib/base.php
@@ -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');
diff --git a/lib/cache/file.php b/lib/cache/file.php
index 562c3d17167..7298ba9074c 100644
--- a/lib/cache/file.php
+++ b/lib/cache/file.php
@@ -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();
+ }
}