getFileListing now returns sorted list
authorFuad Muhic <fmuhic@capeannenterprises.com>
Fri, 26 Jan 2018 14:59:47 +0000 (15:59 +0100)
committerFuad Muhic <fmuhic@capeannenterprises.com>
Fri, 26 Jan 2018 14:59:47 +0000 (15:59 +0100)
Arvados-DCO-1.1-Signed-off-by: Fuad Muhic <fmuhic@capeannenterprises.com>

sdk/R/R/Collection.R
sdk/R/R/CollectionTree.R
sdk/R/R/Subcollection.R

index 203aaff8cbc7b33e5f92cf39b3d16abd1e9b5033..8d49cd0decbf8cdcd93473ba11b8cf9ddfc97c2a 100644 (file)
@@ -142,7 +142,11 @@ Collection <- R6::R6Class(
             elementToMove$move(newLocation)
         },
 
-        getFileListing = function() private$REST$getCollectionContent(self$uuid),
+        getFileListing = function()
+        {
+            content <- private$REST$getCollectionContent(self$uuid)
+            content[order(tolower(content))]
+        },
 
         get = function(relativePath)
         {
index 40cedef6b6eaa5a709264c24af20bc73cd1b45cd..fcc5dbece5727a35656700169130677af744158d 100644 (file)
@@ -96,6 +96,11 @@ CollectionTree <- R6::R6Class(
             }
             else
             {
+                # Note: REST always returns folder name alone before other folder content
+                # (for some reason), so in first iteration we don't know if it's a file
+                # or folder since its just a name, so we assume it's a file. 
+                # If we encounter that same name again we know 
+                # it's a folder so we need to replace ArvadosFile with Subcollection.
                 if("ArvadosFile" %in% class(child))
                 {
                     child = private$replaceFileWithSubcollection(child)
index c42e7e55be9c61d4d258d5dc5da0c6c22d402ccf..a1f83f51bf81213531df7679e68736443b21ccfc 100644 (file)
@@ -117,7 +117,7 @@ Subcollection <- R6::R6Class(
                     content <- c(content, child$getName())
             }
 
-            content
+            content[order(tolower(content))]
         },
 
         getSizeInBytes = function()