예제 #1
0
 /**
  * @brief Erase a file's versions which exceed the set quota
  */
 public static function expire($filename)
 {
     if (\OCP\Config::getSystemValue('files_versions', Storage::DEFAULTENABLED) == 'true') {
         list($uid, $filename) = self::getUidAndFilename($filename);
         $versions_fileview = new \OC_FilesystemView('/' . $uid . '/files_versions');
         $versionsName = \OCP\Config::getSystemValue('datadirectory') . $versions_fileview->getAbsolutePath($filename);
         // check for old versions
         $matches = glob($versionsName . '.v*');
         if (count($matches) > \OCP\Config::getSystemValue('files_versionmaxversions', Storage::DEFAULTMAXVERSIONS)) {
             $numberToDelete = count($matches) - \OCP\Config::getSystemValue('files_versionmaxversions', Storage::DEFAULTMAXVERSIONS);
             // delete old versions of a file
             $deleteItems = array_slice($matches, 0, $numberToDelete);
             foreach ($deleteItems as $de) {
                 unlink($versionsName . '.v' . $de);
             }
         }
     }
 }
예제 #2
0
 public static function removeETagHook($params, $root = false)
 {
     if (isset($params['path'])) {
         $path = $params['path'];
     } else {
         $path = $params['oldpath'];
     }
     if ($root) {
         // reduce path to the required part of it (no 'username/files')
         $fakeRootView = new OC_FilesystemView($root);
         $count = 1;
         $path = str_replace(OC_App::getStorage("files")->getAbsolutePath($path), "", $fakeRootView->getAbsolutePath($path), $count);
     }
     $path = self::normalizePath($path);
     OC_Connector_Sabre_Node::removeETagPropertyForPath($path);
 }