From 14b4a1acc30cf4c84135ec7580d228ad1aacca17 Mon Sep 17 00:00:00 2001 From: Fuad Muhic Date: Fri, 26 Jan 2018 15:59:47 +0100 Subject: [PATCH] getFileListing now returns sorted list Arvados-DCO-1.1-Signed-off-by: Fuad Muhic --- sdk/R/R/Collection.R | 6 +++++- sdk/R/R/CollectionTree.R | 5 +++++ sdk/R/R/Subcollection.R | 2 +- 3 files changed, 11 insertions(+), 2 deletions(-) diff --git a/sdk/R/R/Collection.R b/sdk/R/R/Collection.R index 203aaff8cb..8d49cd0dec 100644 --- a/sdk/R/R/Collection.R +++ b/sdk/R/R/Collection.R @@ -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) { diff --git a/sdk/R/R/CollectionTree.R b/sdk/R/R/CollectionTree.R index 40cedef6b6..fcc5dbece5 100644 --- a/sdk/R/R/CollectionTree.R +++ b/sdk/R/R/CollectionTree.R @@ -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) diff --git a/sdk/R/R/Subcollection.R b/sdk/R/R/Subcollection.R index c42e7e55be..a1f83f51bf 100644 --- a/sdk/R/R/Subcollection.R +++ b/sdk/R/R/Subcollection.R @@ -117,7 +117,7 @@ Subcollection <- R6::R6Class( content <- c(content, child$getName()) } - content + content[order(tolower(content))] }, getSizeInBytes = function() -- 2.30.2