Merge pull request #6890 from owncloud/version_fix_array_order
[files_versions] fix array order
This commit is contained in:
commit
4474421ada
|
@ -5,7 +5,8 @@ $source = $_GET['source'];
|
||||||
$start = $_GET['start'];
|
$start = $_GET['start'];
|
||||||
list ($uid, $filename) = OCA\Files_Versions\Storage::getUidAndFilename($source);
|
list ($uid, $filename) = OCA\Files_Versions\Storage::getUidAndFilename($source);
|
||||||
$count = 5; //show the newest revisions
|
$count = 5; //show the newest revisions
|
||||||
if( ($versions = OCA\Files_Versions\Storage::getVersions($uid, $filename, $source)) ) {
|
$versions = OCA\Files_Versions\Storage::getVersions($uid, $filename, $source);
|
||||||
|
if( $versions ) {
|
||||||
|
|
||||||
$endReached = false;
|
$endReached = false;
|
||||||
if (count($versions) <= $start+$count) {
|
if (count($versions) <= $start+$count) {
|
||||||
|
|
|
@ -264,7 +264,7 @@ class Storage {
|
||||||
* @param string $uid user id from the owner of the file
|
* @param string $uid user id from the owner of the file
|
||||||
* @param string $filename file to find versions of, relative to the user files dir
|
* @param string $filename file to find versions of, relative to the user files dir
|
||||||
* @param string $userFullPath
|
* @param string $userFullPath
|
||||||
* @returns array
|
* @returns array versions newest version first
|
||||||
*/
|
*/
|
||||||
public static function getVersions($uid, $filename, $userFullPath = '') {
|
public static function getVersions($uid, $filename, $userFullPath = '') {
|
||||||
$versions = array();
|
$versions = array();
|
||||||
|
@ -397,12 +397,13 @@ class Storage {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
ksort($versions);
|
// newest version first
|
||||||
|
krsort($versions);
|
||||||
|
|
||||||
$result = array();
|
$result = array();
|
||||||
|
|
||||||
foreach ($versions as $key => $value) {
|
foreach ($versions as $key => $value) {
|
||||||
$size = $view->filesize($value['path']);
|
$size = $view->filesize(self::VERSIONS_ROOT.'/'.$value['path'].'.v'.$value['timestamp']);
|
||||||
$filename = $value['path'];
|
$filename = $value['path'];
|
||||||
|
|
||||||
$result['all'][$key]['version'] = $value['timestamp'];
|
$result['all'][$key]['version'] = $value['timestamp'];
|
||||||
|
@ -428,8 +429,6 @@ class Storage {
|
||||||
$size = 0;
|
$size = 0;
|
||||||
$toDelete = array(); // versions we want to delete
|
$toDelete = array(); // versions we want to delete
|
||||||
|
|
||||||
$versions = array_reverse($versions); // newest version first
|
|
||||||
|
|
||||||
$interval = 1;
|
$interval = 1;
|
||||||
$step = Storage::$max_versions_per_interval[$interval]['step'];
|
$step = Storage::$max_versions_per_interval[$interval]['step'];
|
||||||
if (Storage::$max_versions_per_interval[$interval]['intervalEndsAfter'] == -1) {
|
if (Storage::$max_versions_per_interval[$interval]['intervalEndsAfter'] == -1) {
|
||||||
|
|
|
@ -40,7 +40,7 @@ class Test_Files_Versioning extends \PHPUnit_Framework_TestCase {
|
||||||
$startTime = 5000000;
|
$startTime = 5000000;
|
||||||
|
|
||||||
$testClass = new VersionStorageToTest();
|
$testClass = new VersionStorageToTest();
|
||||||
list($deleted, $size) = $testClass->callProtectedGetExpireList($startTime, array_reverse($versions));
|
list($deleted, $size) = $testClass->callProtectedGetExpireList($startTime, $versions);
|
||||||
|
|
||||||
// we should have deleted 16 files each of the size 1
|
// we should have deleted 16 files each of the size 1
|
||||||
$this->assertEquals($sizeOfAllDeletedFiles, $size);
|
$this->assertEquals($sizeOfAllDeletedFiles, $size);
|
||||||
|
|
Loading…
Reference in New Issue