Esempio n. 1
0
/**
 * The FileCache Upgrade routine
 *
 * @param UpdateWatcher $watcher
 */
function __doFileCacheUpgrade($watcher)
{
    try {
        $query = \OC_DB::prepare('
			SELECT DISTINCT `user`
			FROM `*PREFIX*fscache`
		');
        $result = $query->execute();
    } catch (\Exception $e) {
        return;
    }
    $users = $result->fetchAll();
    if (count($users) == 0) {
        return;
    }
    $step = 100 / count($users);
    $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');
}
Esempio n. 2
0
    private function upgradeFileCache()
    {
        try {
            $query = \OC_DB::prepare('
				SELECT DISTINCT `user`
				FROM `*PREFIX*fscache`
			');
            $result = $query->execute();
        } catch (\Exception $e) {
            return;
        }
        $users = $result->fetchAll();
        if (count($users) == 0) {
            return;
        }
        $step = 100 / count($users);
        $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
                $this->emit('\\OC\\Updater', 'filecacheStart');
                $startInfoShown = true;
            }
            $percentCompleted += $step;
            $out = floor($percentCompleted);
            if ($out != $lastPercentCompletedOutput) {
                $this->emit('\\OC\\Updater', 'filecacheProgress', array($out));
                $lastPercentCompletedOutput = $out;
            }
        }
        $this->emit('\\OC\\Updater', 'filecacheDone');
    }