Skip to content

Commit

Permalink
folder permission fix - windows
Browse files Browse the repository at this point in the history
  • Loading branch information
amankgo committed Jan 12, 2022
1 parent 7b8bb18 commit 8ea02eb
Showing 1 changed file with 9 additions and 3 deletions.
12 changes: 9 additions & 3 deletions src/main/kotlin/storage/StorageHelper.kt
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,11 @@ import utils.DbCreationException
import utils.reportException
import java.io.File
import java.io.IOException
import java.nio.file.FileSystems
import java.nio.file.Files
import java.nio.file.attribute.PosixFilePermissions


object StorageHelper {

internal fun createDiskDb(): DB {
Expand Down Expand Up @@ -39,11 +41,15 @@ object StorageHelper {
folder.delete()
}
try {
Files.createDirectory(
folder.toPath(), PosixFilePermissions.asFileAttribute(
val isPosix = FileSystems.getDefault().supportedFileAttributeViews().contains("posix")
if (isPosix) {
val posixAttribute = PosixFilePermissions.asFileAttribute(
PosixFilePermissions.fromString("rwxr-x---")
)
)
Files.createDirectory(folder.toPath(), posixAttribute)
} else {
Files.createDirectory(folder.toPath())
}
} catch (e: IOException) {
throw IOException("Cannot create app folder at path ${folder.canonicalPath}", e)
}
Expand Down

0 comments on commit 8ea02eb

Please sign in to comment.