示例#1
0
 /**
  * get the free space in the users home folder
  * @return int
  */
 private function getFreeSpace()
 {
     $rootInfo = OC_FileCache_Cached::get('');
     // TODO Remove after merge of share_api
     if (OC_FileCache::inCache('/Shared')) {
         $sharedInfo = OC_FileCache_Cached::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;
 }
示例#2
0
<?php

// Load other apps for file previews
OC_App::loadApps();
// Compatibility with shared-by-link items from ownCloud 4.0
// requires old Sharing table !
// support will be removed in OC 5.0,a
if (isset($_GET['token'])) {
    unset($_GET['file']);
    $qry = \OC_DB::prepare('SELECT `source` FROM `*PREFIX*sharing` WHERE `target` = ? LIMIT 1');
    $filepath = $qry->execute(array($_GET['token']))->fetchOne();
    if (isset($filepath)) {
        $info = OC_FileCache_Cached::get($filepath, '');
        if (strtolower($info['mimetype']) == 'httpd/unix-directory') {
            $_GET['dir'] = $filepath;
        } else {
            $_GET['file'] = $filepath;
        }
        \OCP\Util::writeLog('files_sharing', 'You have files that are shared by link originating from ownCloud 4.0. Redistribute the new links, because backwards compatibility will be removed in ownCloud 5.', \OCP\Util::WARN);
    }
}
// Enf of backward compatibility
if (isset($_GET['file']) || isset($_GET['dir'])) {
    if (isset($_GET['dir'])) {
        $type = 'folder';
        $path = $_GET['dir'];
        $baseDir = $path;
        $dir = $baseDir;
    } else {
        $type = 'file';
        $path = $_GET['file'];
示例#3
0
 /**
  * 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);
 }
示例#4
0
 /**
  * get all files and folders in a folder
  * @param string path
  * @param string root (optional)
  * @return array
  *
  * returns an array of assiciative arrays with the following keys:
  * - name
  * - size
  * - mtime
  * - ctime
  * - mimetype
  * - encrypted
  * - versioned
  */
 public static function getFolderContent($path, $root = false, $mimetype_filter = '')
 {
     if (OC_FileCache_Update::hasUpdated($path, $root, true)) {
         OC_FileCache_Update::updateFolder($path, $root);
     }
     return OC_FileCache_Cached::getFolderContent($path, $root, $mimetype_filter);
 }
示例#5
0
 /**
  * Returns available diskspace information
  *
  * @return array
  */
 public function getQuotaInfo()
 {
     $rootInfo = OC_FileCache_Cached::get('');
     return array($rootInfo['size'], OC_Filesystem::free_space());
 }
示例#6
0
 public function postFileSize($path, $size)
 {
     if (self::isEncrypted($path)) {
         $cached = OC_FileCache_Cached::get($path, '');
         return $cached['size'];
     } else {
         return $size;
     }
 }
示例#7
0
 /**
  * adjust the size of the parent folders
  * @param string $path
  * @param int $sizeDiff
  * @param string root (optinal)
  */
 public static function increaseSize($path, $sizeDiff, $root = false)
 {
     if ($sizeDiff == 0) {
         return;
     }
     $item = OC_FileCache_Cached::get($path);
     //stop walking up the filetree if we hit a non-folder
     if ($item['mimetype'] !== 'httpd/unix-directory') {
         return;
     }
     $id = $item['id'];
     while ($id != -1) {
         //walk up the filetree increasing the size of all parent folders
         $query = OC_DB::prepare('UPDATE `*PREFIX*fscache` SET `size`=`size`+? WHERE `id`=?');
         $query->execute(array($sizeDiff, $id));
         if ($path == '' or $path == '/') {
             return;
         }
         $path = dirname($path);
         $parent = OC_FileCache_Cached::get($path);
         $id = $parent['id'];
         //stop walking up the filetree if we hit a non-folder
         if ($parent['mimetype'] !== 'httpd/unix-directory') {
             return;
         }
     }
 }