Skip to content

Commit

Permalink
On dataset upload, create orga dir if it does not exist (#8230)
Browse files Browse the repository at this point in the history
* On dataset upload, create orga dir if it does not exist

* changelog
  • Loading branch information
fm3 authored Nov 26, 2024
1 parent bf6ea15 commit 0d2e029
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 2 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.unreleased.md
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ For upgrade instructions, please check the [migration guide](MIGRATIONS.released
- 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)
- 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)
- 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)
- Fix a bug where dataset uploads would fail if the organization directory on disk is missing. [#8230](https://github.com/scalableminds/webknossos/pull/8230)

### Removed
- Removed Google Analytics integration. [#8201](https://github.com/scalableminds/webknossos/pull/8201)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ import com.scalableminds.webknossos.datastore.models.datasource._
import com.scalableminds.webknossos.datastore.models.datasource.inbox.{InboxDataSource, UnusableDataSource}
import com.scalableminds.webknossos.datastore.storage.RemoteSourceDescriptorService
import com.typesafe.scalalogging.LazyLogging
import net.liftweb.common.Box.tryo
import net.liftweb.common._
import play.api.inject.ApplicationLifecycle
import play.api.libs.json.Json
Expand Down Expand Up @@ -53,8 +54,17 @@ class DataSourceService @Inject()(
if (inboxCheckVerboseCounter >= 10) inboxCheckVerboseCounter = 0
}

def assertDataDirWritable(organizationId: String): Fox[Unit] =
Fox.bool2Fox(Files.isWritable(dataBaseDir.resolve(organizationId))) ?~> "Datastore cannot write to its data directory."
def assertDataDirWritable(organizationId: String): Fox[Unit] = {
val orgaPath = dataBaseDir.resolve(organizationId)
if (orgaPath.toFile.exists()) {
Fox.bool2Fox(Files.isWritable(dataBaseDir.resolve(organizationId))) ?~> "Datastore cannot write to organization data directory."
} else {
tryo {
Files.createDirectory(orgaPath)
}.map(_ => ()).toFox ?~> "Could not create organization directory on datastore server"
}

}

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

0 comments on commit 0d2e029

Please sign in to comment.