Improved GVFS error logging: GVFS: %s => %s
This commit is contained in:
parent
16a36757a7
commit
e3f46c56b5
@ -3,6 +3,7 @@ package net.filebot.gio;
|
|||||||
|
|
||||||
import java.io.File;
|
import java.io.File;
|
||||||
import java.net.URI;
|
import java.net.URI;
|
||||||
|
import java.util.Optional;
|
||||||
|
|
||||||
public class PlatformGVFS implements GVFS {
|
public class PlatformGVFS implements GVFS {
|
||||||
|
|
||||||
@ -25,24 +26,34 @@ public class PlatformGVFS implements GVFS {
|
|||||||
// e.g. afp://reinhard@10.0.1.5/data/Movies/Avatar.mp4 -> /run/user/1000/gvfs/afp-volume:host=10.0.1.5,user=reinhard,volume=data/Movies/Avatar.mp4
|
// e.g. afp://reinhard@10.0.1.5/data/Movies/Avatar.mp4 -> /run/user/1000/gvfs/afp-volume:host=10.0.1.5,user=reinhard,volume=data/Movies/Avatar.mp4
|
||||||
// e.g. sftp://reinhard@10.0.1.5/home/Movies/Avatar.mp4 -> /run/user/1000/gvfs/sftp:host=10.0.1.5,user=reinhard/home/Movies/Avatar.mp4
|
// e.g. sftp://reinhard@10.0.1.5/home/Movies/Avatar.mp4 -> /run/user/1000/gvfs/sftp:host=10.0.1.5,user=reinhard/home/Movies/Avatar.mp4
|
||||||
|
|
||||||
// guess GVFS folder based on keywords (see https://wiki.gnome.org/Projects/gvfs/doc)
|
String protocol = uri.getScheme();
|
||||||
for (String mount : gvfs.list()) {
|
String host = uri.getHost();
|
||||||
if (mount.startsWith(uri.getScheme()) && mount.contains(uri.getHost())) {
|
String user = uri.getUserInfo();
|
||||||
if (uri.getUserInfo() != null && !mount.contains(uri.getUserInfo()))
|
String port = Optional.of(uri.getPort()).filter(i -> i > 0).map(Object::toString).orElse(null);
|
||||||
continue;
|
|
||||||
if (uri.getPort() > 0 && !mount.contains(String.valueOf(uri.getPort())))
|
|
||||||
continue;
|
|
||||||
|
|
||||||
String path = uri.getPath().substring(1);
|
String path = uri.getPath().substring(1);
|
||||||
String share = path.substring(0, path.indexOf('/'));
|
String volume = null;
|
||||||
|
|
||||||
if (mount.endsWith(share)) {
|
if (protocol.equals("smb") || protocol.equals("afp")) {
|
||||||
path = path.substring(share.length()).substring(1);
|
volume = path.substring(0, path.indexOf('/'));
|
||||||
|
path = path.substring(volume.length()).substring(1);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// guess GVFS folder based on keywords (see https://wiki.gnome.org/Projects/gvfs/doc)
|
||||||
|
for (String mount : gvfs.list()) {
|
||||||
|
if (!mount.startsWith(protocol))
|
||||||
|
continue;
|
||||||
|
if (!mount.contains(host) && !(mount.endsWith("server=" + host) || mount.endsWith("host=" + host)))
|
||||||
|
continue;
|
||||||
|
if (volume != null && !(mount.endsWith("share=" + volume) || mount.endsWith("volume=" + volume)))
|
||||||
|
continue;
|
||||||
|
if (user != null && !mount.contains("user=" + user))
|
||||||
|
continue;
|
||||||
|
if (port != null && !mount.contains("port=" + port))
|
||||||
|
continue;
|
||||||
|
|
||||||
return new File(new File(gvfs, mount), path);
|
return new File(new File(gvfs, mount), path);
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
throw new IllegalArgumentException("Failed to locate local path: " + uri);
|
throw new IllegalArgumentException("Failed to locate local path: " + uri);
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user