diff options
author | Björn Schießle <schiessle@owncloud.com> | 2012-12-13 16:34:54 +0100 |
---|---|---|
committer | Björn Schießle <schiessle@owncloud.com> | 2012-12-17 11:39:57 +0100 |
commit | 24d4f701bf3fb0f9a785523bcf39af0a66e5be48 (patch) | |
tree | b3db0f8b93bef843bde828951d3371002572f47d /apps/files_versions | |
parent | e16be33384e49276ef9b483b6c8f667ad688e372 (diff) | |
download | nextcloud-server-24d4f701bf3fb0f9a785523bcf39af0a66e5be48.tar.gz nextcloud-server-24d4f701bf3fb0f9a785523bcf39af0a66e5be48.zip |
calculate free space for versions
Diffstat (limited to 'apps/files_versions')
-rw-r--r-- | apps/files_versions/lib/versions.php | 32 |
1 files changed, 29 insertions, 3 deletions
diff --git a/apps/files_versions/lib/versions.php b/apps/files_versions/lib/versions.php index 0ccaaf1095d..8e209a130c4 100644 --- a/apps/files_versions/lib/versions.php +++ b/apps/files_versions/lib/versions.php @@ -31,8 +31,8 @@ class Storage { const DEFAULTENABLED=true; const DEFAULTBLACKLIST='avi mp3 mpg mp4 ctmp'; - const DEFAULTMAXFILESIZE=1048576; // 10MB - const DEFAULTMININTERVAL=60; // 1 min + const DEFAULTMAXFILESIZE=10485760; // 10MB + const DEFAULTMININTERVAL=1; // 1 min const DEFAULTMAXVERSIONS=50; private static function getUidAndFilename($filename) @@ -245,11 +245,37 @@ class Storage { if(\OCP\Config::getSystemValue('files_versions', Storage::DEFAULTENABLED)=='true') { list($uid, $filename) = self::getUidAndFilename($filename); $versions_fileview = new \OC_FilesystemView('/'.$uid.'/files_versions'); - + $quota = \OCP\Util::computerFileSize(\OC_Preferences::getValue($uid, 'files', 'quota')); + if ( $quota == null ) { + $quota = \OCP\Util::computerFileSize(\OC_Appconfig::getValue('files', 'default_quota')); + } else if ( $quota == null ) { + $quota = \OC_Filesystem::free_space('/'); + } +
+ $rootInfo = OC_FileCache::get('', '/'. $uid . '/files'); + $free = $quota-$rootInfo['size']; + + if ( $free > 0 ) { + $availableSpace = 5000 / ($quota-$rootInfo['size']); // 50% of free space can be used for versions + } else { + $availableSpace = 0; + } + $versionsName=\OCP\Config::getSystemValue('datadirectory').$versions_fileview->getAbsolutePath($filename); // check for old versions $matches = glob( $versionsName.'.v*' ); + +
+ foreach ( $matches as $m ) error_log("version: " . $m);
+
+ //day interval
+
+ //week interval
+
+ //month interval
+
+ //delete oldest if( count( $matches ) > \OCP\Config::getSystemValue( 'files_versionmaxversions', Storage::DEFAULTMAXVERSIONS ) ) { |