Skip to content

Interpret paths without scheme to be file in DataVaultService #8761

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 5 commits into from
Jul 9, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions unreleased_changes/8761.md
Original file line number Diff line number Diff line change
@@ -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.
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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}

Expand Down Expand Up @@ -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.")
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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")
Expand Down