summaryrefslogtreecommitdiffstats
path: root/core/ajax/update.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 /core/ajax/update.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 'core/ajax/update.php')
-rw-r--r--core/ajax/update.php45
1 files changed, 45 insertions, 0 deletions
diff --git a/core/ajax/update.php b/core/ajax/update.php
index 8b20150d432..a2fc72f511c 100644
--- a/core/ajax/update.php
+++ b/core/ajax/update.php
@@ -14,6 +14,10 @@ if (OC::checkUpgrade(false)) {
try {
$result = OC_DB::updateDbFromStructure(OC::$SERVERROOT.'/db_structure.xml');
$watcher->success('Updated database');
+
+ // do a file cache upgrade for users with files
+ // this can take loooooooooooooooooooooooong
+ __doFileCacheUpgrade($watcher);
} catch (Exception $exception) {
$watcher->failure($exception->getMessage());
}
@@ -26,6 +30,47 @@ if (OC::checkUpgrade(false)) {
$watcher->done();
}
+/**
+ * The FileCache Upgrade routine
+ *
+ * @param UpdateWatcher $watcher
+ */
+function __doFileCacheUpgrade($watcher) {
+ file_put_contents('/tmp/debug', "START\n", FILE_APPEND);
+ $query = \OC_DB::prepare('
+ SELECT DISTINCT user
+ FROM`*PREFIX*fscache`
+ ');
+ $result = $query->execute();
+ $users = $result->fetchAll();
+ if(count($users) == 0) {
+ return;
+ }
+ $step = 100 / count($users);
+ file_put_contents('/tmp/debug', 'Step '. print_r($step, true)."\n", FILE_APPEND);
+ $percentCompleted = 0;
+ $lastPercentCompletedOutput = 0;
+ $startInfoShown = false;
+ foreach($users as $userRow) {
+ $user = $userRow['user'];
+ \OC\Files\Filesystem::initMountPoints($user);
+ \OC\Files\Cache\Upgrade::doSilentUpgrade($user);
+ if(!$startInfoShown) {
+ //We show it only now, because otherwise Info about upgraded apps
+ //will appear between this and progress info
+ $watcher->success('Updating filecache, this may take really long...');
+ $startInfoShown = true;
+ }
+ $percentCompleted += $step;
+ $out = floor($percentCompleted);
+ if($out != $lastPercentCompletedOutput) {
+ $watcher->success('... '. $out.'% done ...');
+ $lastPercentCompletedOutput = $out;
+ }
+ }
+ $watcher->success('Updated filecache');
+}
+
class UpdateWatcher {
/**
* @var \OC_EventSource $eventSource;