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. 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..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 == 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" 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..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 @@ -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 != 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.") } 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")