mirror of
https://github.com/enso-org/enso.git
synced 2024-12-19 00:31:39 +03:00
Project Manager fails to create directory when one exists (#11804)
close #11758 Changelog: - update: FileSystemService fails to create directory if one exists
This commit is contained in:
parent
106e112cea
commit
485840fefd
@ -73,7 +73,10 @@ class BlockingFileSystem[F[+_, +_]: Sync: ErrorChannel](
|
||||
/** @inheritdoc */
|
||||
override def createDir(path: File): F[FileSystemFailure, Unit] =
|
||||
Sync[F]
|
||||
.blockingOp { FileUtils.forceMkdir(path) }
|
||||
.blockingOp {
|
||||
if (path.exists()) throw new FileExistsException()
|
||||
FileUtils.forceMkdir(path)
|
||||
}
|
||||
.mapError(toFsFailure)
|
||||
.timeoutFail(OperationTimeout)(ioTimeout)
|
||||
|
||||
|
@ -110,6 +110,29 @@ class FileSystemServiceSpec
|
||||
FileUtils.deleteQuietly(directoryPath)
|
||||
}
|
||||
|
||||
"create directory fail when one exists with the same name" in {
|
||||
val testDir = testStorageConfig.userProjectsPath
|
||||
|
||||
val directoryName = "filesystem_test_create_dir_with_same_name"
|
||||
val directoryPath = new File(testDir, directoryName)
|
||||
|
||||
val result1 = fileSystemService
|
||||
.createDirectory(directoryPath)
|
||||
.unsafeRunSync()
|
||||
|
||||
result1 shouldEqual Right(())
|
||||
Files.isDirectory(directoryPath.toPath) shouldEqual true
|
||||
|
||||
val result2 = fileSystemService
|
||||
.createDirectory(directoryPath)
|
||||
.unsafeRunSync()
|
||||
|
||||
result2.isLeft shouldEqual true
|
||||
|
||||
// cleanup
|
||||
FileUtils.deleteQuietly(directoryPath)
|
||||
}
|
||||
|
||||
"delete directory" in {
|
||||
implicit val client: WsTestClient = new WsTestClient(address)
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user