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

Commit

Permalink
remove joda-time runtime dependency (it's already present in test sco…
Browse files Browse the repository at this point in the history
…pe and not really needed in main)
  • Loading branch information
romangrebennikov committed Aug 28, 2016
1 parent a09ab85 commit 003816d
Show file tree
Hide file tree
Showing 4 changed files with 10 additions and 9 deletions.
1 change: 0 additions & 1 deletion build.sbt
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@ libraryDependencies ++= Seq(
"com.typesafe.akka" %% "akka-stream" % akkaVersion,
"com.typesafe.akka" %% "akka-http-experimental" % akkaVersion,
"org.scala-lang.modules" %% "scala-xml" % "1.0.5",
"joda-time" % "joda-time" % "2.9.4",
"com.github.pathikrit" %% "better-files" % "2.16.0",
"com.typesafe.scala-logging" %% "scala-logging" % "3.4.0",
"org.scalatest" %% "scalatest" % "3.0.0" % "test",
Expand Down
8 changes: 4 additions & 4 deletions src/main/scala/io/findify/s3mock/provider/FileProvider.scala
Original file line number Diff line number Diff line change
Expand Up @@ -2,28 +2,28 @@ package io.findify.s3mock.provider
import java.nio.charset.Charset
import java.util.{Base64, UUID}

import akka.http.scaladsl.model.DateTime
import better.files.File
import better.files.File.OpenOptions
import com.typesafe.scalalogging.LazyLogging
import io.findify.s3mock.error.{NoSuchBucketException, NoSuchKeyException}
import io.findify.s3mock.request.{CompleteMultipartUpload, CreateBucketConfiguration}
import io.findify.s3mock.response._
import org.joda.time.{DateTime, LocalDateTime}
import scala.util.Random

/**
* Created by shutty on 8/9/16.
*/
class FileProvider(dir:String) extends Provider with LazyLogging {
def listBuckets: ListAllMyBuckets = {
val buckets = File(dir).list.map(f => Bucket(f.name, new DateTime(f.lastModifiedTime.toEpochMilli))).toList
val buckets = File(dir).list.map(f => Bucket(f.name, DateTime(f.lastModifiedTime.toEpochMilli))).toList
logger.debug(s"listing buckets: ${buckets.map(_.name)}")
ListAllMyBuckets("root", UUID.randomUUID().toString, buckets)
}

def listBucket(bucket: String, prefix: String) = {
val files = if (File(s"$dir/$bucket/$prefix").isDirectory) {
File(s"$dir/$bucket/$prefix").list.filterNot(_.name.startsWith(".")).map(f => Content(s"$prefix/${f.name}", new DateTime(f.lastModifiedTime.toEpochMilli), "0", f.size, "STANDARD"))
File(s"$dir/$bucket/$prefix").list.filterNot(_.name.startsWith(".")).map(f => Content(s"$prefix/${f.name}", DateTime(f.lastModifiedTime.toEpochMilli), "0", f.size, "STANDARD"))
} else {
val fullPath = prefix.split("/").filter(_.nonEmpty)
val filter = fullPath.last
Expand All @@ -35,7 +35,7 @@ class FileProvider(dir:String) extends Provider with LazyLogging {
.filter(_.name.startsWith(filter))
.map(f => {
val filePath = List(parent, f.name).filter(_.nonEmpty).mkString("/")
Content(filePath, new DateTime(f.lastModifiedTime.toEpochMilli), "0", f.size, "STANDARD")
Content(filePath, DateTime(f.lastModifiedTime.toEpochMilli), "0", f.size, "STANDARD")
})
else
List()
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package io.findify.s3mock.response

import org.joda.time.DateTime
import akka.http.scaladsl.model.DateTime


/**
* Created by shutty on 8/9/16.
Expand All @@ -18,7 +19,7 @@ case class ListAllMyBuckets(ownerName:String, ownerUUID:String, buckets:List[Buc
buckets.map(bucket =>
<Bucket>
<Name>{bucket.name}</Name>
<CreationDate>{bucket.creationDate.toString}</CreationDate>
<CreationDate>{bucket.creationDate.toString}Z</CreationDate>
</Bucket>)
}
</Buckets>
Expand Down
5 changes: 3 additions & 2 deletions src/main/scala/io/findify/s3mock/response/ListBucket.scala
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package io.findify.s3mock.response

import org.joda.time.DateTime
import akka.http.scaladsl.model.DateTime


/**
* Created by shutty on 8/9/16.
Expand All @@ -17,7 +18,7 @@ case class ListBucket(bucket:String, prefix:String, contents:List[Content]) {
{contents.map(content =>
<Contents>
<Key>{content.key}</Key>
<LastModified>{content.lastModified.toString}</LastModified>
<LastModified>{content.lastModified.toString}Z</LastModified>
<ETag>{content.md5}</ETag>
<Size>{content.size}</Size>
<StorageClass>{content.storageClass}</StorageClass>
Expand Down

0 comments on commit 003816d

Please sign in to comment.