Skip to content

Commit 0d2e029

Browse files
authored
On dataset upload, create orga dir if it does not exist (#8230)
* On dataset upload, create orga dir if it does not exist * changelog
1 parent bf6ea15 commit 0d2e029

File tree

2 files changed

+13
-2
lines changed

2 files changed

+13
-2
lines changed

CHANGELOG.unreleased.md

+1
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@ For upgrade instructions, please check the [migration guide](MIGRATIONS.released
2323
- Fix a bug where changing the color of a segment via the menu in the segments tab would update the segment color of the previous segment, on which the context menu was opened. [#8225](https://github.com/scalableminds/webknossos/pull/8225)
2424
- Fix a bug when importing an NML with groups when only groups but no trees exist in an annotation. [#8176](https://github.com/scalableminds/webknossos/pull/8176)
2525
- Fix a bug where trying to delete a non-existing node (via the API, for example) would delete the whole active tree. [#8176](https://github.com/scalableminds/webknossos/pull/8176)
26+
- Fix a bug where dataset uploads would fail if the organization directory on disk is missing. [#8230](https://github.com/scalableminds/webknossos/pull/8230)
2627

2728
### Removed
2829
- Removed Google Analytics integration. [#8201](https://github.com/scalableminds/webknossos/pull/8201)

webknossos-datastore/app/com/scalableminds/webknossos/datastore/services/DataSourceService.scala

+12-2
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@ import com.scalableminds.webknossos.datastore.models.datasource._
1414
import com.scalableminds.webknossos.datastore.models.datasource.inbox.{InboxDataSource, UnusableDataSource}
1515
import com.scalableminds.webknossos.datastore.storage.RemoteSourceDescriptorService
1616
import com.typesafe.scalalogging.LazyLogging
17+
import net.liftweb.common.Box.tryo
1718
import net.liftweb.common._
1819
import play.api.inject.ApplicationLifecycle
1920
import play.api.libs.json.Json
@@ -53,8 +54,17 @@ class DataSourceService @Inject()(
5354
if (inboxCheckVerboseCounter >= 10) inboxCheckVerboseCounter = 0
5455
}
5556

56-
def assertDataDirWritable(organizationId: String): Fox[Unit] =
57-
Fox.bool2Fox(Files.isWritable(dataBaseDir.resolve(organizationId))) ?~> "Datastore cannot write to its data directory."
57+
def assertDataDirWritable(organizationId: String): Fox[Unit] = {
58+
val orgaPath = dataBaseDir.resolve(organizationId)
59+
if (orgaPath.toFile.exists()) {
60+
Fox.bool2Fox(Files.isWritable(dataBaseDir.resolve(organizationId))) ?~> "Datastore cannot write to organization data directory."
61+
} else {
62+
tryo {
63+
Files.createDirectory(orgaPath)
64+
}.map(_ => ()).toFox ?~> "Could not create organization directory on datastore server"
65+
}
66+
67+
}
5868

5969
def checkInbox(verbose: Boolean): Fox[Unit] = {
6070
if (verbose) logger.info(s"Scanning inbox ($dataBaseDir)...")

0 commit comments

Comments
 (0)