summaryrefslogtreecommitdiffstats
path: root/apps/files_versions/lib
diff options
context:
space:
mode:
authorTom Needham <tom@owncloud.com>2013-03-09 00:04:33 +0000
committerTom Needham <tom@owncloud.com>2013-03-09 00:04:33 +0000
commite58dbd46fc4648ca6f33b83e7ce7745f07217477 (patch)
treee71722b44bf58d64e30addc4e6685855d62c5db5 /apps/files_versions/lib
parent370f202251df2425ec49c78265859a804a88433f (diff)
parent546fb72b25fb8ebdc70aa75ccc7a095d7d83b174 (diff)
downloadnextcloud-server-e58dbd46fc4648ca6f33b83e7ce7745f07217477.tar.gz
nextcloud-server-e58dbd46fc4648ca6f33b83e7ce7745f07217477.zip
Merge in master
Diffstat (limited to 'apps/files_versions/lib')
-rw-r--r--apps/files_versions/lib/versions.php20
1 files changed, 14 insertions, 6 deletions
diff --git a/apps/files_versions/lib/versions.php b/apps/files_versions/lib/versions.php
index 178ef722735..20611c61ec7 100644
--- a/apps/files_versions/lib/versions.php
+++ b/apps/files_versions/lib/versions.php
@@ -61,7 +61,7 @@ class Storage {
}
return false;
}
-
+
/**
* write to the database how much space is in use for versions
*
@@ -82,6 +82,14 @@ class Storage {
*/
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');
@@ -442,12 +450,12 @@ class Storage {
}
}
- // check if enough space is available after versions are rearranged.
- // if not we delete the oldest versions until we meet the size limit for versions
- $numOfVersions = count($all_versions);
+ // Check if enough space is available after versions are rearranged.
+ // If not we delete the oldest versions until we meet the size limit for versions,
+ // but always keep the two latest versions
+ $numOfVersions = count($all_versions) -2 ;
$i = 0;
- while ($availableSpace < 0) {
- if ($i = $numOfVersions-2) break; // keep at least the last version
+ while ($availableSpace < 0 && $i < $numOfVersions) {
$versions_fileview->unlink($all_versions[$i]['path'].'.v'.$all_versions[$i]['version']);
$versionsSize -= $all_versions[$i]['size'];
$availableSpace += $all_versions[$i]['size'];