fix expire function

This commit is contained in:
Björn Schießle 2013-03-04 17:20:14 +01:00
parent ef70978524
commit 70014d37dc

View file

@ -442,12 +442,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'];