Skip to content
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

Fix FileRangeReaderProvider parsing URI in windows #3507

Merged
merged 1 commit into from
Mar 15, 2023
Merged
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
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,6 @@ package geotrellis.util
import java.net.URI
import java.nio.file.Paths


class FileRangeReaderProvider extends RangeReaderProvider {
def canProcess(uri: URI): Boolean = uri.getScheme match {
case str: String => if (str.toLowerCase == "file") true else false
Expand All @@ -32,14 +31,17 @@ class FileRangeReaderProvider extends RangeReaderProvider {
// URIs that are correctly formatted from being used. To
// get around this, we will pass in the URI as a String
// instead without its Scheme (if it had one).
val isWindows = System.getProperty("os.name").toLowerCase().startsWith("win")
val targetPath: String = {
val uriString = uri.toString

if (uriString.startsWith("file://"))
uriString.slice("file://".size, uriString.size + 1)
else if (uriString.startsWith("file:"))
uriString.slice("file:".size, uriString.size + 1)
else
if (uriString.startsWith("file://")) {
val from = if (isWindows) "file:///" else "file://"
uriString.slice(from.size, uriString.size + 1)
} else if (uriString.startsWith("file:")) {
val from = if (isWindows) "file:/" else "file:"
uriString.slice(from.size, uriString.size + 1)
} else
uriString
}

Expand Down