Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Project Manager fails to create directory when one exists #11804

Merged
merged 1 commit into from
Dec 9, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -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()
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

exists also works as expected on case-insensitive file systems. No other checks needed

FileUtils.forceMkdir(path)
}
.mapError(toFsFailure)
.timeoutFail(OperationTimeout)(ioTimeout)

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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)

Expand Down
Loading