/** * get the free space in the users home folder * @return int */ private function getFreeSpace() { $rootInfo = OC_FileCache::get(''); // TODO Remove after merge of share_api if (OC_FileCache::inCache('/Shared')) { $sharedInfo = OC_FileCache::get('/Shared'); } else { $sharedInfo = null; } $usedSpace = isset($rootInfo['size']) ? $rootInfo['size'] : 0; $usedSpace = isset($sharedInfo['size']) ? $usedSpace - $sharedInfo['size'] : $usedSpace; $totalSpace = $this->getQuota(); if ($totalSpace == 0) { return 0; } return $totalSpace - $usedSpace; }
/** * get the free space in the path's owner home folder * @param path * @return int */ private function getFreeSpace($path) { $storage = OC_Filesystem::getStorage($path); $owner = $storage->getOwner($path); $totalSpace = $this->getQuota($owner); if ($totalSpace == -1) { return -1; } $rootInfo = OC_FileCache::get('', "/" . $owner . "/files"); // TODO Remove after merge of share_api if (OC_FileCache::inCache('/Shared', "/" . $owner . "/files")) { $sharedInfo = OC_FileCache::get('/Shared', "/" . $owner . "/files"); } else { $sharedInfo = null; } $usedSpace = isset($rootInfo['size']) ? $rootInfo['size'] : 0; $usedSpace = isset($sharedInfo['size']) ? $usedSpace - $sharedInfo['size'] : $usedSpace; return $totalSpace - $usedSpace; }
/** * update the filesystem after a rename has been detected * @param string oldPath * @param string newPath * @param string root (optional) */ public static function rename($oldPath, $newPath, $root = false) { if (!OC_FileCache::inCache($oldPath, $root)) { return; } if ($root === false) { $view = OC_Filesystem::getView(); } else { $view = new OC_FilesystemView($root); } $cached = OC_FileCache_Cached::get($oldPath, $root); $oldSize = $cached['size']; OC_FileCache::increaseSize(dirname($oldPath), -$oldSize, $root); OC_FileCache::increaseSize(dirname($newPath), $oldSize, $root); OC_FileCache::move($oldPath, $newPath); }
<?php set_time_limit(0); //scanning can take ages $force = isset($_GET['force']) and $_GET['force'] == 'true'; $dir = isset($_GET['dir']) ? $_GET['dir'] : ''; $checkOnly = isset($_GET['checkonly']) and $_GET['checkonly'] == 'true'; if (!$checkOnly) { $eventSource = new OC_EventSource(); } //create the file cache if necesary if ($force or !OC_FileCache::inCache('')) { if (!$checkOnly) { OCP\DB::beginTransaction(); OC_FileCache::scan($dir, $eventSource); OC_FileCache::clean(); OCP\DB::commit(); $eventSource->send('success', true); } else { OCP\JSON::success(array('data' => array('done' => true))); exit; } } else { if ($checkOnly) { OCP\JSON::success(array('data' => array('done' => false))); exit; } if (isset($eventSource)) { $eventSource->send('success', false); } else { exit;