Skip to content
This repository has been archived by the owner on Dec 4, 2023. It is now read-only.

Commit

Permalink
fix getCommonPrefixes ordering bug (#41)
Browse files Browse the repository at this point in the history
  • Loading branch information
romangrebennikov committed Apr 24, 2017
1 parent 7660e99 commit 632ad3a
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ class FileProvider(dir:String) extends Provider with LazyLogging {
val files = bucketFiles.map(f => {Content(f.toString.drop(bucketFileString.length+1).dropWhile(_ == '/'), DateTime(f.lastModifiedTime.toEpochMilli), "0", f.size, "STANDARD")}).toList
logger.debug(s"listing bucket contents: ${files.map(_.key)}")
val commonPrefixes = delimiter match {
case Some(del) => files.flatMap(f => commonPrefix(f.key, prefixNoLeadingSlash, del)).distinct
case Some(del) => files.flatMap(f => commonPrefix(f.key, prefixNoLeadingSlash, del)).distinct.sorted
case None => Nil
}
val filteredFiles = files.filterNot(f => commonPrefixes.exists(p => f.key.startsWith(p)))
Expand Down
4 changes: 2 additions & 2 deletions src/test/scala/io/findify/s3mock/ListBucketTest.scala
Original file line number Diff line number Diff line change
Expand Up @@ -154,14 +154,14 @@ class ListBucketTest extends S3MockTest {
s3.putObject("list7", "dev/40/2017/03/13/00/_SUCCESS", "xxx")
s3.putObject("list7", "dev/40/2017/03/13/01/_SUCCESS", "xxx")
s3.putObject("list7", "dev/50/2017/03/13/00/_SUCCESS", "xxx")
s3.putObject("list7", "dev/60/2017/03/13/01/_SUCCESS", "xxx")
s3.putObject("list7", "dev/50/2017/03/13/01/_SUCCESS", "xxx")
val req2 = new ListObjectsRequest()
req2.setBucketName("list7")
req2.setDelimiter("/")
req2.setPrefix("dev/")
val list2 = s3.listObjects(req2)
val summaries2 = list2.getObjectSummaries.map(_.getKey).toList
list2.getCommonPrefixes.asScala.toList shouldBe List("dev/10", "dev/20", "dev/30", "dev/40", "dev/50")
list2.getCommonPrefixes.asScala.toList shouldBe List("dev/10/", "dev/20/", "dev/30/", "dev/40/", "dev/50/")
summaries2 shouldBe Nil
}
}
Expand Down

0 comments on commit 632ad3a

Please sign in to comment.