Skip to content

Commit c6bed41

Browse files
authored
Interpret paths without scheme to be file in DataVaultService (#8761)
URIs with no scheme should be assumed to be file. This already worked in some circumstances because we do some normalization via Path.of(stuff).toUri, which adds the file scheme, but this doesn’t happen in all cases. ### Steps to test: - Create dataset with an attachment specified with an absolute path, e.g. ``` "attachments": { "agglomerates": [ { "name": "agglomerate_view_70", "dataFormat": "zarr3", "path": "/home/agglomerate_view_70" } ] }, ``` - Agglomerate mapping should be applied correctly. ### Issues: - fixes https://scm.slack.com/archives/C5AKLAV0B/p1751900152180879?thread_ts=1751888599.160149&cid=C5AKLAV0B - follow-up refactoring: #8762 ------ - [x] Added changelog entry (create a `$PR_NUMBER.md` file in `unreleased_changes` or use `./tools/create-changelog-entry.py`) - [x] Considered [common edge cases](../blob/master/.github/common_edge_cases.md) - [x] Needs datastore update after deployment
1 parent 38cc8ac commit c6bed41

File tree

4 files changed

+6
-3
lines changed

4 files changed

+6
-3
lines changed

unreleased_changes/8761.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
### Fixed
2+
- Fixed a bug where dataset layer attachments with absolute paths would not get loaded unless the paths are specified with file:// scheme.

webknossos-datastore/app/com/scalableminds/webknossos/datastore/datavault/FileSystemDataVault.scala

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -94,7 +94,7 @@ class FileSystemDataVault extends DataVault {
9494
private def vaultPathToLocalPath(path: VaultPath)(implicit ec: ExecutionContext): Fox[Path] = {
9595
val uri = path.toUri
9696
for {
97-
_ <- Fox.fromBool(uri.getScheme == DataVaultService.schemeFile) ?~> "trying to read from FileSystemDataVault, but uri scheme is not file"
97+
_ <- Fox.fromBool(uri.getScheme == null || uri.getScheme == DataVaultService.schemeFile) ?~> "trying to read from FileSystemDataVault, but uri scheme is not file or null"
9898
_ <- Fox.fromBool(uri.getHost == null || uri.getHost.isEmpty) ?~> s"trying to read from FileSystemDataVault, but hostname ${uri.getHost} is non-empty"
9999
localPath = Paths.get(uri.getPath)
100100
_ <- Fox.fromBool(localPath.isAbsolute) ?~> "trying to read from FileSystemDataVault, but hostname is non-empty"

webknossos-datastore/app/com/scalableminds/webknossos/datastore/models/datasource/DatasetLayerAttachments.scala

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ package com.scalableminds.webknossos.datastore.models.datasource
33
import com.scalableminds.util.enumeration.ExtendedEnumeration
44
import com.scalableminds.util.io.PathUtils
55
import com.scalableminds.util.tools.{Box, Full}
6+
import com.scalableminds.webknossos.datastore.storage.DataVaultService
67
import org.apache.commons.io.FilenameUtils
78
import play.api.libs.json.{Format, Json}
89

@@ -41,7 +42,7 @@ case class LayerAttachment(name: String,
4142
credentialId: Option[String] = None) {
4243
// Warning: throws! Use inside of tryo
4344
def localPath: Path = {
44-
if (path.getScheme.nonEmpty && path.getScheme != "file") {
45+
if (path.getScheme != null && path.getScheme.nonEmpty && path.getScheme != DataVaultService.schemeFile) {
4546
throw new Exception(
4647
"Trying to open non-local hdf5 file. Hdf5 files are only supported on the datastore-local file system.")
4748
}

webknossos-datastore/app/com/scalableminds/webknossos/datastore/storage/DataVaultService.scala

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,7 @@ class DataVaultService @Inject()(ws: WSClient, config: DataStoreConfig) extends
5555
S3DataVault.create(remoteSource, ws)
5656
} else if (scheme == DataVaultService.schemeHttps || scheme == DataVaultService.schemeHttp) {
5757
HttpsDataVault.create(remoteSource, ws, config.Http.uri)
58-
} else if (scheme == DataVaultService.schemeFile) {
58+
} else if (scheme == DataVaultService.schemeFile || scheme == null) {
5959
FileSystemDataVault.create
6060
} else {
6161
throw new Exception(s"Unknown file system scheme $scheme")

0 commit comments

Comments
 (0)