fix array access and change variable names according to the coding style

This commit is contained in:
Björn Schießle 2013-06-28 20:31:33 +02:00
parent 15f7bb296c
commit b16c5a6df7
1 changed files with 13 additions and 11 deletions

View File

@ -398,7 +398,7 @@ class Storage {
private static function expire($filename, $versionsSize = null, $offset = 0) { private static function expire($filename, $versionsSize = null, $offset = 0) {
if(\OCP\Config::getSystemValue('files_versions', Storage::DEFAULTENABLED)=='true') { if(\OCP\Config::getSystemValue('files_versions', Storage::DEFAULTENABLED)=='true') {
list($uid, $filename) = self::getUidAndFilename($filename); list($uid, $filename) = self::getUidAndFilename($filename);
$versions_fileview = new \OC\Files\View('/'.$uid.'/files_versions'); $versionsFileview = new \OC\Files\View('/'.$uid.'/files_versions');
// get available disk space for user // get available disk space for user
$softQuota = true; $softQuota = true;
@ -445,20 +445,20 @@ class Storage {
$allFiles = false; $allFiles = false;
} }
$all_versions = Storage::getVersions($uid, $filename); $allVersions = Storage::getVersions($uid, $filename);
$versions_by_file[$filename] = $all_versions; $versionsByFile[$filename] = $allVersions;
$sizeOfDeletedVersions = self::delOldVersions($versions_by_file, $all_versions, $versions_fileview); $sizeOfDeletedVersions = self::delOldVersions($versionsByFile, $allVersions, $versionsFileview);
$availableSpace = $availableSpace + $sizeOfDeletedVersions; $availableSpace = $availableSpace + $sizeOfDeletedVersions;
$versionsSize = $versionsSize - $sizeOfDeletedVersions; $versionsSize = $versionsSize - $sizeOfDeletedVersions;
// if still not enough free space we rearrange the versions from all files // if still not enough free space we rearrange the versions from all files
if ($availableSpace <= 0 || $allFiles) { if ($availableSpace <= 0 || $allFiles) {
$result = Storage::getAllVersions($uid); $result = Storage::getAllVersions($uid);
$versions_by_file = $result['by_file']; $versionsByFile = $result['by_file'];
$all_versions = $result['all']; $allVersions = $result['all'];
$sizeOfDeletedVersions = self::delOldVersions($versions_by_file, $all_versions, $versions_fileview); $sizeOfDeletedVersions = self::delOldVersions($versionsByFile, $allVersions, $versionsFileview);
$availableSpace = $availableSpace + $sizeOfDeletedVersions; $availableSpace = $availableSpace + $sizeOfDeletedVersions;
$versionsSize = $versionsSize - $sizeOfDeletedVersions; $versionsSize = $versionsSize - $sizeOfDeletedVersions;
} }
@ -466,12 +466,14 @@ class Storage {
// Check if enough space is available after versions are rearranged. // 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, // If not we delete the oldest versions until we meet the size limit for versions,
// but always keep the two latest versions // but always keep the two latest versions
$numOfVersions = count($all_versions) -2 ; $numOfVersions = count($allVersions) -2 ;
$i = 0; $i = 0;
while ($availableSpace < 0 && $i < $numOfVersions) { while ($availableSpace < 0 && $i < $numOfVersions) {
$versions_fileview->unlink($all_versions[$i]['path'].'.v'.$all_versions[$i]['version']); $version = current($allVersions);
$versionsSize -= $all_versions[$i]['size']; $versionsFileview->unlink($version['path'].'.v'.$version['version']);
$availableSpace += $all_versions[$i]['size']; $versionsSize -= $version['size'];
$availableSpace += $version['size'];
next($allVersions);
$i++; $i++;
} }