/**
* get current size of all versions from a given user
- *
+ *
* @param $user user who owns the versions
* @return mixed versions size or false if no versions size is stored
*/
private static function getVersionsSize($user) {
$query = \OC_DB::prepare('SELECT `size` FROM `*PREFIX*files_versions` WHERE `user`=?');
$result = $query->execute(array($user))->fetchAll();
-
+
if ($result) {
return $result[0]['size'];
}
/**
* write to the database how much space is in use for versions
- *
+ *
* @param $user owner of the versions
* @param $size size of the versions
*/
}
$query->execute(array($size, $user));
}
-
+
/**
* store a new version of a file.
*/
public static function store($filename) {
if(\OCP\Config::getSystemValue('files_versions', Storage::DEFAULTENABLED)=='true') {
-
+
// if the file gets streamed we need to remove the .part extension
// to get the right target
$ext = pathinfo($filename, PATHINFO_EXTENSION);
if ($ext === 'part') {
$filename = substr($filename, 0, strlen($filename)-5);
}
-
+
list($uid, $filename) = self::getUidAndFilename($filename);
$files_view = new \OC\Files\View('/'.$uid .'/files');
// we should have a source file to work with, and the file shouldn't
// be empty
$fileExists = $files_view->file_exists($filename);
- $fileSize = $files_view->filesize($filename);
- if ($fileExists === false || $fileSize === 0) {
+ if (!($fileExists && $files_view->filesize($filename) > 0)) {
return false;
}
list($uidn, $newpath) = self::getUidAndFilename($new_path);
$versions_view = new \OC\Files\View('/'.$uid .'/files_versions');
$files_view = new \OC\Files\View('/'.$uid .'/files');
-
+
// if the file already exists than it was a upload of a existing file
// over the web interface -> store() is the right function we need here
if ($files_view->file_exists($newpath)) {
} else {
$quota = \OCP\Util::computerFileSize($quota);
}
-
+
// make sure that we have the current size of the version history
if ( $versionsSize === null ) {
$versionsSize = self::getVersionsSize($uid);