aboutsummaryrefslogtreecommitdiff
path: root/src/main/scala/xyz/driver/core/file/FileSystemStorage.scala
diff options
context:
space:
mode:
authorJakob Odersky <jakob@driver.xyz>2017-06-21 15:06:20 -0700
committerJakob Odersky <jakob@driver.xyz>2017-06-21 16:40:27 -0700
commite41050b75308aab2736eea11b67bf9387a90dfe5 (patch)
tree4138f96ec7381b54c1339cb6577198ae067486e3 /src/main/scala/xyz/driver/core/file/FileSystemStorage.scala
parentc5bc3df97dd7670d6271efe440068b44f6521562 (diff)
downloaddriver-core-e41050b75308aab2736eea11b67bf9387a90dfe5.tar.gz
driver-core-e41050b75308aab2736eea11b67bf9387a90dfe5.tar.bz2
driver-core-e41050b75308aab2736eea11b67bf9387a90dfe5.zip
Add file existence checking to file storagev0.13.15
Diffstat (limited to 'src/main/scala/xyz/driver/core/file/FileSystemStorage.scala')
-rw-r--r--src/main/scala/xyz/driver/core/file/FileSystemStorage.scala15
1 files changed, 10 insertions, 5 deletions
diff --git a/src/main/scala/xyz/driver/core/file/FileSystemStorage.scala b/src/main/scala/xyz/driver/core/file/FileSystemStorage.scala
index bfe6995..fab1307 100644
--- a/src/main/scala/xyz/driver/core/file/FileSystemStorage.scala
+++ b/src/main/scala/xyz/driver/core/file/FileSystemStorage.scala
@@ -1,7 +1,7 @@
package xyz.driver.core.file
import java.io.File
-import java.nio.file.{Path, Paths}
+import java.nio.file.{Files, Path, Paths}
import xyz.driver.core.{Name, Revision}
import xyz.driver.core.time.Time
@@ -12,7 +12,7 @@ import scalaz.{ListT, OptionT}
class FileSystemStorage(executionContext: ExecutionContext) extends FileStorage {
implicit private val execution = executionContext
- def upload(localSource: File, destination: Path): Future[Unit] = Future {
+ override def upload(localSource: File, destination: Path): Future[Unit] = Future {
checkSafeFileName(destination) {
val destinationFile = destination.toFile
@@ -28,12 +28,12 @@ class FileSystemStorage(executionContext: ExecutionContext) extends FileStorage
}
}
- def download(filePath: Path): OptionT[Future, File] =
+ override def download(filePath: Path): OptionT[Future, File] =
OptionT.optionT(Future {
Option(new File(filePath.toString)).filter(file => file.exists() && file.isFile)
})
- def delete(filePath: Path): Future[Unit] = Future {
+ override def delete(filePath: Path): Future[Unit] = Future {
val file = new File(filePath.toString)
if (file.delete()) ()
else {
@@ -41,7 +41,7 @@ class FileSystemStorage(executionContext: ExecutionContext) extends FileStorage
}
}
- def list(path: Path): ListT[Future, FileLink] =
+ override def list(path: Path): ListT[Future, FileLink] =
ListT.listT(Future {
val file = new File(path.toString)
if (file.isDirectory) {
@@ -54,4 +54,9 @@ class FileSystemStorage(executionContext: ExecutionContext) extends FileStorage
}
} else List.empty[FileLink]
})
+
+ override def exists(path: Path): Future[Boolean] = Future {
+ Files.exists(path)
+ }
+
}