qupath icon indicating copy to clipboard operation
qupath copied to clipboard

Fix IllegalArgumentException for network share URIs on windows

Open ap-- opened this issue 1 year ago • 3 comments

Dear QuPath developers,

Quite some time ago a user of paquo reported a bug with network share URIs on windows, see: https://github.com/bayer-science-for-a-better-life/paquo/issues/65

This PR get's rid of the immediate issue in ImageServerProvider.getServerBuilders, but I'm not sure if there's more bugs further downstream using network share URIs.

The fix boils down to using java.nio.Paths.get(uri).toFile() instead of java.io.File(uri) directly. (see: https://github.com/bayer-science-for-a-better-life/paquo/issues/65#issuecomment-970711915)

I am currently unable to test this myself due to lack of access to a windows machine.

Cheers, Andreas 😃

ap-- avatar Sep 08 '22 10:09 ap--

Thanks @ap--!

From a quick search of the QuPath code, we do use new File(uri) in quite a lot of places, so I'd like to understand better what the problem is to see if we need to eliminate it entirely.

I had a look at the other discussion, but I'm still fuzzy on the real-world implications and how I could properly test any fix.

I saw the combination of URIs that do and don't work and I also saw

print(java.io.File(java.net.URI("file://localhost/c$/Windows")).exists()) # fails URI has an authority component (bug as this is completely valid path)

but I guess I don't understand when and why that matters, or if the URI could simply be given in some other way?

Unfortunately, I use Windows very rarely, network shares on Windows even less, and don't know much about more exotic URIs...

petebankhead avatar Sep 08 '22 11:09 petebankhead

but I guess I don't understand when and why that matters, or if the URI could simply be given in some other way?

Unfortunately, I use Windows very rarely, network shares on Windows even less, and don't know much about more exotic URIs...

tbh it's the same for me. So far as I understand, it's currently impossible to use valid file URIs on windows that are not mapped to a network drive. i.e.

file://networkshare/c$/file.svs

I am not 100% sure if it's possible to use files on network shares, when they are mapped to a network drive, i.e.

file:///M:/file.svs

And I should actually try this on a windows laptop first to verify. Initially, I was hoping that this might be some issue you're already aware of, and that the source of the bug might be obvious. I'll report back once I've tested this manually with QuPath on windows.

ap-- avatar Sep 08 '22 13:09 ap--

Ah, thanks. I think the second scenario is the only one I've ever worked with myself - I'll also see if I can replicate it somehow.

petebankhead avatar Sep 08 '22 13:09 petebankhead