From 1f729b1b3a1cd1e289dd8df245b755300338897e Mon Sep 17 00:00:00 2001 From: Florian M Date: Mon, 7 Jul 2025 17:13:25 +0200 Subject: [PATCH 1/4] Interpret paths without scheme to be file in DataVaultService --- .../webknossos/datastore/datavault/FileSystemDataVault.scala | 2 +- .../datastore/models/datasource/DatasetLayerAttachments.scala | 3 ++- .../webknossos/datastore/storage/DataVaultService.scala | 2 +- 3 files changed, 4 insertions(+), 3 deletions(-) diff --git a/webknossos-datastore/app/com/scalableminds/webknossos/datastore/datavault/FileSystemDataVault.scala b/webknossos-datastore/app/com/scalableminds/webknossos/datastore/datavault/FileSystemDataVault.scala index 85a05da9162..910adcc05d7 100644 --- a/webknossos-datastore/app/com/scalableminds/webknossos/datastore/datavault/FileSystemDataVault.scala +++ b/webknossos-datastore/app/com/scalableminds/webknossos/datastore/datavault/FileSystemDataVault.scala @@ -94,7 +94,7 @@ class FileSystemDataVault extends DataVault { private def vaultPathToLocalPath(path: VaultPath)(implicit ec: ExecutionContext): Fox[Path] = { val uri = path.toUri for { - _ <- Fox.fromBool(uri.getScheme == DataVaultService.schemeFile) ?~> "trying to read from FileSystemDataVault, but uri scheme is not file" + _ <- Fox.fromBool(uri.getScheme == null || uri.getScheme == DataVaultService.schemeFile) ?~> "trying to read from FileSystemDataVault, but uri scheme is not file" _ <- Fox.fromBool(uri.getHost == null || uri.getHost.isEmpty) ?~> s"trying to read from FileSystemDataVault, but hostname ${uri.getHost} is non-empty" localPath = Paths.get(uri.getPath) _ <- Fox.fromBool(localPath.isAbsolute) ?~> "trying to read from FileSystemDataVault, but hostname is non-empty" diff --git a/webknossos-datastore/app/com/scalableminds/webknossos/datastore/models/datasource/DatasetLayerAttachments.scala b/webknossos-datastore/app/com/scalableminds/webknossos/datastore/models/datasource/DatasetLayerAttachments.scala index 8a8138d5e75..0a709b1270d 100644 --- a/webknossos-datastore/app/com/scalableminds/webknossos/datastore/models/datasource/DatasetLayerAttachments.scala +++ b/webknossos-datastore/app/com/scalableminds/webknossos/datastore/models/datasource/DatasetLayerAttachments.scala @@ -3,6 +3,7 @@ package com.scalableminds.webknossos.datastore.models.datasource import com.scalableminds.util.enumeration.ExtendedEnumeration import com.scalableminds.util.io.PathUtils import com.scalableminds.util.tools.{Box, Full} +import com.scalableminds.webknossos.datastore.storage.DataVaultService import org.apache.commons.io.FilenameUtils import play.api.libs.json.{Format, Json} @@ -41,7 +42,7 @@ case class LayerAttachment(name: String, credentialId: Option[String] = None) { // Warning: throws! Use inside of tryo def localPath: Path = { - if (path.getScheme.nonEmpty && path.getScheme != "file") { + if (path.getScheme.nonEmpty && path.getScheme != DataVaultService.schemeFile) { throw new Exception( "Trying to open non-local hdf5 file. Hdf5 files are only supported on the datastore-local file system.") } diff --git a/webknossos-datastore/app/com/scalableminds/webknossos/datastore/storage/DataVaultService.scala b/webknossos-datastore/app/com/scalableminds/webknossos/datastore/storage/DataVaultService.scala index a7d295aeba2..9f6f384d5d9 100644 --- a/webknossos-datastore/app/com/scalableminds/webknossos/datastore/storage/DataVaultService.scala +++ b/webknossos-datastore/app/com/scalableminds/webknossos/datastore/storage/DataVaultService.scala @@ -55,7 +55,7 @@ class DataVaultService @Inject()(ws: WSClient, config: DataStoreConfig) extends S3DataVault.create(remoteSource, ws) } else if (scheme == DataVaultService.schemeHttps || scheme == DataVaultService.schemeHttp) { HttpsDataVault.create(remoteSource, ws, config.Http.uri) - } else if (scheme == DataVaultService.schemeFile) { + } else if (scheme == DataVaultService.schemeFile || scheme == null) { FileSystemDataVault.create } else { throw new Exception(s"Unknown file system scheme $scheme") From 42f87643835078a388cbffa5b093c0b74e463114 Mon Sep 17 00:00:00 2001 From: Florian M Date: Mon, 7 Jul 2025 17:14:25 +0200 Subject: [PATCH 2/4] changelog --- unreleased_changes/8761.md | 2 ++ 1 file changed, 2 insertions(+) create mode 100644 unreleased_changes/8761.md diff --git a/unreleased_changes/8761.md b/unreleased_changes/8761.md new file mode 100644 index 00000000000..2cfcd48afd3 --- /dev/null +++ b/unreleased_changes/8761.md @@ -0,0 +1,2 @@ +### Fixed +- Fixed a bug where dataset layer attachments with absolute paths would not get loaded unless the paths are specified with file:// scheme. From f0b0dd7bbd63b98ad79867290044ce7575e98d96 Mon Sep 17 00:00:00 2001 From: Florian M Date: Mon, 7 Jul 2025 17:36:09 +0200 Subject: [PATCH 3/4] catch null pointer --- .../datastore/models/datasource/DatasetLayerAttachments.scala | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/webknossos-datastore/app/com/scalableminds/webknossos/datastore/models/datasource/DatasetLayerAttachments.scala b/webknossos-datastore/app/com/scalableminds/webknossos/datastore/models/datasource/DatasetLayerAttachments.scala index 0a709b1270d..a884b5c69d0 100644 --- a/webknossos-datastore/app/com/scalableminds/webknossos/datastore/models/datasource/DatasetLayerAttachments.scala +++ b/webknossos-datastore/app/com/scalableminds/webknossos/datastore/models/datasource/DatasetLayerAttachments.scala @@ -42,7 +42,7 @@ case class LayerAttachment(name: String, credentialId: Option[String] = None) { // Warning: throws! Use inside of tryo def localPath: Path = { - if (path.getScheme.nonEmpty && path.getScheme != DataVaultService.schemeFile) { + if (path.getScheme != null && path.getScheme.nonEmpty && path.getScheme != DataVaultService.schemeFile) { throw new Exception( "Trying to open non-local hdf5 file. Hdf5 files are only supported on the datastore-local file system.") } From 9e0e8f1a8d8c84060ac0bca260c9ad82bc506c7d Mon Sep 17 00:00:00 2001 From: Florian M Date: Wed, 9 Jul 2025 09:00:14 +0200 Subject: [PATCH 4/4] adapt error message --- .../webknossos/datastore/datavault/FileSystemDataVault.scala | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/webknossos-datastore/app/com/scalableminds/webknossos/datastore/datavault/FileSystemDataVault.scala b/webknossos-datastore/app/com/scalableminds/webknossos/datastore/datavault/FileSystemDataVault.scala index 910adcc05d7..b26eefd7d5d 100644 --- a/webknossos-datastore/app/com/scalableminds/webknossos/datastore/datavault/FileSystemDataVault.scala +++ b/webknossos-datastore/app/com/scalableminds/webknossos/datastore/datavault/FileSystemDataVault.scala @@ -94,7 +94,7 @@ class FileSystemDataVault extends DataVault { private def vaultPathToLocalPath(path: VaultPath)(implicit ec: ExecutionContext): Fox[Path] = { val uri = path.toUri for { - _ <- Fox.fromBool(uri.getScheme == null || uri.getScheme == DataVaultService.schemeFile) ?~> "trying to read from FileSystemDataVault, but uri scheme is not file" + _ <- Fox.fromBool(uri.getScheme == null || uri.getScheme == DataVaultService.schemeFile) ?~> "trying to read from FileSystemDataVault, but uri scheme is not file or null" _ <- Fox.fromBool(uri.getHost == null || uri.getHost.isEmpty) ?~> s"trying to read from FileSystemDataVault, but hostname ${uri.getHost} is non-empty" localPath = Paths.get(uri.getPath) _ <- Fox.fromBool(localPath.isAbsolute) ?~> "trying to read from FileSystemDataVault, but hostname is non-empty"