Skip to content

Commit

Permalink
fix initial creation of top-level folders
Browse files Browse the repository at this point in the history
  • Loading branch information
memo33 committed Oct 13, 2024
1 parent 2ebf0d0 commit a9b6648
Showing 1 changed file with 3 additions and 1 deletion.
4 changes: 3 additions & 1 deletion src/main/scala/sc4pac/api/api.scala
Original file line number Diff line number Diff line change
Expand Up @@ -122,6 +122,7 @@ class Api(options: sc4pac.cli.Commands.ServerOptions) {
pluginsRoot = os.Path(initArgs.plugins, profileRoot)
cacheRoot = os.Path(initArgs.cache, profileRoot)
_ <- ZIO.attemptBlockingIO {
os.makeDir.all(profileRoot)
os.makeDir.all(pluginsRoot) // TODO ask for confirmation?
os.makeDir.all(cacheRoot)
}
Expand Down Expand Up @@ -368,6 +369,7 @@ class Api(options: sc4pac.cli.Commands.ServerOptions) {
ps <- JD.Profiles.readOrInit
(ps2, p) = ps.add(profileName.name)
jsonPath <- JD.Profiles.pathURIO
_ <- ZIO.attemptBlockingIO { os.makeDir.all(jsonPath / os.up) }
_ <- JsonIo.write(jsonPath, ps2, None)(ZIO.succeed(()))
} yield jsonResponse(p)
}
Expand All @@ -376,6 +378,6 @@ class Api(options: sc4pac.cli.Commands.ServerOptions) {
)

(profileRoutes2 ++ genericRoutes)
.handleError(err => jsonResponse(ErrorMessage.ServerError("Unhandled error.", err.getMessage)).status(Status.InternalServerError))
.handleError(err => jsonResponse(ErrorMessage.ServerError("Unhandled error.", err.toString)).status(Status.InternalServerError))
}
}

0 comments on commit a9b6648

Please sign in to comment.