From 21cdf93616f78bc199d32af5426993ce523adb37 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Bj=C3=B6rn=20Schie=C3=9Fle?= <schiessle@owncloud.com>
Date: Tue, 18 Dec 2012 12:57:28 +0100
Subject: [PATCH] remove DEFAULTMAXFILESIZE limit and make percentage of
 available space for versions configurable

---
 apps/files_versions/lib/versions.php | 10 ++--------
 1 file changed, 2 insertions(+), 8 deletions(-)

diff --git a/apps/files_versions/lib/versions.php b/apps/files_versions/lib/versions.php
index 8cf28490d4..46ae434518 100644
--- a/apps/files_versions/lib/versions.php
+++ b/apps/files_versions/lib/versions.php
@@ -27,8 +27,7 @@ class Storage {
 	//   - add transparent compression. first test if it´s worth it.
 
 	const DEFAULTENABLED=true;
-	const DEFAULTMAXFILESIZE=10485760; // 10MB
-	const DEFAULTMAXVERSIONS=50;
+	const DEFAULTMAXSIZE=50; // unit: percentage; 50% of available disk space/quota
 	
 	private static $max_versions_per_interval = array(1 => array('intervalEndsAfter' => 3600,     //first hour, one version every 10sec
 																	'step' => 10),
@@ -80,11 +79,6 @@ class Storage {
 				return false;
 			}
 
-			// check filesize
-			if($files_view->filesize($filename)>\OCP\Config::getSystemValue('files_versionsmaxfilesize', Storage::DEFAULTMAXFILESIZE)) {
-				return false;
-			}
-
 			// create all parent folders
 			$info=pathinfo($filename);
 			if(!file_exists($versionsFolderName.'/'.$info['dirname'])) {
@@ -248,7 +242,7 @@ class Storage {
 			$free = $quota-$rootInfo['size']; // remaining free space for user
 
 			if ( $free > 0 ) {
-				$availableSpace = 5000 / ($quota-$rootInfo['size']); // 50% of free space can be used for versions
+				$availableSpace = 100* self::DEFAULTMAXSIZE / ($quota-$rootInfo['size']); // how much space can be used for versions
 			} // otherwise available space negative and we need to reach at least 0 at the end of the expiration process;
 			
 			$versions = Storage::getVersions($filename);
-- 
GitLab