summaryrefslogtreecommitdiffstats
path: root/lib/files/cache/upgrade.php
diff options
context:
space:
mode:
authorArthur Schiwon <blizzz@owncloud.com>2013-03-22 23:33:40 +0100
committerArthur Schiwon <blizzz@owncloud.com>2013-03-27 19:12:28 +0100
commite2afd0cb42af17a968d6fbefac7372d13b71399a (patch)
treeca5be3aa1140da9320d3e522e92494537e628a27 /lib/files/cache/upgrade.php
parent9d25058905f8a50e729397052d39eb84dcb9fe01 (diff)
downloadnextcloud-server-e2afd0cb42af17a968d6fbefac7372d13b71399a.tar.gz
nextcloud-server-e2afd0cb42af17a968d6fbefac7372d13b71399a.zip
Upgrade FileCache on ownCloud upgrade for all users with files
Diffstat (limited to 'lib/files/cache/upgrade.php')
-rw-r--r--lib/files/cache/upgrade.php22
1 files changed, 21 insertions, 1 deletions
diff --git a/lib/files/cache/upgrade.php b/lib/files/cache/upgrade.php
index efb06a2b943..47184615b46 100644
--- a/lib/files/cache/upgrade.php
+++ b/lib/files/cache/upgrade.php
@@ -36,7 +36,6 @@ class Upgrade {
return;
}
\OC_Hook::emit('\OC\Files\Cache\Upgrade', 'migrate_path', $path);
-
if ($row = $this->legacy->get($path)) {
$data = $this->getNewData($row);
if ($data) {
@@ -251,4 +250,25 @@ class Upgrade {
static function upgradeDone($user) {
\OCP\Config::setUserValue($user, 'files', 'cache_version', 5);
}
+
+ /**
+ * Does a "silent" upgrade, i.e. without an Event-Source as triggered
+ * on User-Login via Ajax. This method is called within the regular
+ * ownCloud upgrade.
+ *
+ * @param string $user a User ID
+ */
+ public static function doSilentUpgrade($user) {
+ if(!self::needUpgrade($user)) {
+ return;
+ }
+ $legacy = new \OC\Files\Cache\Legacy($user);
+ if ($legacy->hasItems()) {
+ \OC_DB::beginTransaction();
+ $upgrade = new \OC\Files\Cache\Upgrade($legacy);
+ $upgrade->upgradePath('/' . $user . '/files');
+ \OC_DB::commit();
+ }
+ \OC\Files\Cache\Upgrade::upgradeDone($user);
+ }
}