[uploadselectionfilter] Extracted as trait
This commit is contained in:
parent
86a53bf712
commit
5090a78baa
2 changed files with 25 additions and 10 deletions
|
@ -10,7 +10,10 @@ import net.kemitix.s3thorp.awssdk.S3Client
|
||||||
|
|
||||||
import scala.concurrent.Promise
|
import scala.concurrent.Promise
|
||||||
|
|
||||||
class Sync(s3Client: S3Client) extends LocalFileStream with S3MetaDataEnricher {
|
class Sync(s3Client: S3Client)
|
||||||
|
extends LocalFileStream
|
||||||
|
with S3MetaDataEnricher
|
||||||
|
with UploadSelectionFilter {
|
||||||
|
|
||||||
override def objectHead(bucket: String, key: String)=
|
override def objectHead(bucket: String, key: String)=
|
||||||
s3Client.objectHead(bucket, key)
|
s3Client.objectHead(bucket, key)
|
||||||
|
@ -25,15 +28,6 @@ class Sync(s3Client: S3Client) extends LocalFileStream with S3MetaDataEnricher {
|
||||||
}
|
}
|
||||||
} yield ()
|
} yield ()
|
||||||
|
|
||||||
private def uploadRequiredFilter: Either[File, S3MetaData] => Stream[IO, File] = {
|
|
||||||
case Left(file) => Stream(file)
|
|
||||||
case Right(s3Metadata) =>
|
|
||||||
Stream.eval(for {
|
|
||||||
_ <- putStrLn(s"upload required: ${s3Metadata.localFile}")
|
|
||||||
//md5File(localFile)
|
|
||||||
//filter(localHash => options.force || localHash != metadataHash)
|
|
||||||
} yield s3Metadata.localFile)
|
|
||||||
}
|
|
||||||
private def performUpload: File => Stream[IO, Promise[Unit]] =
|
private def performUpload: File => Stream[IO, Promise[Unit]] =
|
||||||
file => Stream.eval(for {
|
file => Stream.eval(for {
|
||||||
_ <- putStrLn(s"upload: $file")
|
_ <- putStrLn(s"upload: $file")
|
||||||
|
|
|
@ -0,0 +1,21 @@
|
||||||
|
package net.kemitix.s3thorp
|
||||||
|
|
||||||
|
import java.io.File
|
||||||
|
|
||||||
|
import fs2.Stream
|
||||||
|
import cats.effect.IO
|
||||||
|
import net.kemitix.s3thorp.Main.putStrLn
|
||||||
|
|
||||||
|
trait UploadSelectionFilter {
|
||||||
|
|
||||||
|
def uploadRequiredFilter: Either[File, S3MetaData] => Stream[IO, File] = {
|
||||||
|
case Left(file) => Stream(file)
|
||||||
|
case Right(s3Metadata) =>
|
||||||
|
Stream.eval(for {
|
||||||
|
_ <- putStrLn(s"upload required: ${s3Metadata.localFile}")
|
||||||
|
//md5File(localFile)
|
||||||
|
//filter(localHash => options.force || localHash != metadataHash)
|
||||||
|
} yield s3Metadata.localFile)
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
Loading…
Reference in a new issue