summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorRobin Appelman <icewind@owncloud.com>2012-11-23 00:17:18 +0100
committerRobin Appelman <icewind@owncloud.com>2012-11-23 00:17:18 +0100
commitad706229f5dbc6382ade61493e9f100a2dc07293 (patch)
tree17d6073c33df7491c6e0d8b05bfc1939f1db2e1f
parent8ce5e0d30d874bf59a81aa01202a497ea4cb8492 (diff)
downloadnextcloud-server-ad706229f5dbc6382ade61493e9f100a2dc07293.tar.gz
nextcloud-server-ad706229f5dbc6382ade61493e9f100a2dc07293.zip
explicitly sort files when using getFolderContents
-rw-r--r--lib/files/cache/cache.php14
-rw-r--r--tests/lib/files/view.php14
2 files changed, 14 insertions, 14 deletions
diff --git a/lib/files/cache/cache.php b/lib/files/cache/cache.php
index b52c0f40677..6b93673097b 100644
--- a/lib/files/cache/cache.php
+++ b/lib/files/cache/cache.php
@@ -33,9 +33,9 @@ class Cache {
* @param \OC\Files\Storage\Storage|string $storage
*/
public function __construct($storage) {
- if($storage instanceof \OC\Files\Storage\Storage){
+ if ($storage instanceof \OC\Files\Storage\Storage) {
$this->storageId = $storage->getId();
- }else{
+ } else {
$this->storageId = $storage;
}
}
@@ -87,7 +87,7 @@ class Cache {
if ($fileId > -1) {
$query = \OC_DB::prepare(
'SELECT `fileid`, `storage`, `path`, `parent`, `name`, `mimetype`, `mimepart`, `size`, `mtime`, `encrypted`
- FROM `*PREFIX*filecache` WHERE parent = ?');
+ FROM `*PREFIX*filecache` WHERE parent = ? ORDER BY `fileid` ASC');
$result = $query->execute(array($fileId));
return $result->fetchAll();
} else {
@@ -364,7 +364,7 @@ class Cache {
*/
public function calculateFolderSize($path) {
$id = $this->getId($path);
- if($id === -1){
+ if ($id === -1) {
return 0;
}
$query = \OC_DB::prepare('SELECT `size` FROM `*PREFIX*filecache` WHERE `parent` = ? AND `storage` = ?');
@@ -412,12 +412,12 @@ class Cache {
*
* @return string|bool the path of the folder or false when no folder matched
*/
- public function getIncomplete(){
+ public function getIncomplete() {
$query = \OC_DB::prepare('SELECT `path` FROM `*PREFIX*filecache` WHERE `storage` = ? AND `size` = -1 ORDER BY `fileid` DESC LIMIT 1');
$query->execute(array($this->storageId));
- if($row = $query->fetchRow()){
+ if ($row = $query->fetchRow()) {
return $row['path'];
- }else{
+ } else {
return false;
}
}
diff --git a/tests/lib/files/view.php b/tests/lib/files/view.php
index a173094b1cc..ecfc803dc23 100644
--- a/tests/lib/files/view.php
+++ b/tests/lib/files/view.php
@@ -55,20 +55,20 @@ class View extends \PHPUnit_Framework_TestCase {
$folderData = $rootView->getDirectoryContent('/');
/**
* expected entries:
- * folder
* foo.png
* foo.txt
+ * folder
* substorage
*/
$this->assertEquals(4, count($folderData));
- $this->assertEquals('folder', $folderData[0]['name']);
- $this->assertEquals('foo.png', $folderData[1]['name']);
- $this->assertEquals('foo.txt', $folderData[2]['name']);
+ $this->assertEquals('foo.png', $folderData[0]['name']);
+ $this->assertEquals('foo.txt', $folderData[1]['name']);
+ $this->assertEquals('folder', $folderData[2]['name']);
$this->assertEquals('substorage', $folderData[3]['name']);
- $this->assertEquals($storageSize + $textSize, $folderData[0]['size']);
- $this->assertEquals($imageSize, $folderData[1]['size']);
- $this->assertEquals($textSize, $folderData[2]['size']);
+ $this->assertEquals($imageSize, $folderData[0]['size']);
+ $this->assertEquals($textSize, $folderData[1]['size']);
+ $this->assertEquals($storageSize + $textSize, $folderData[2]['size']);
$this->assertEquals($storageSize, $folderData[3]['size']);
$folderView = new \OC\Files\View('/folder');