From 6f3f27a005fc677520e3b0c8b3d63232e53b0328 Mon Sep 17 00:00:00 2001 From: Reinhard Pointner Date: Fri, 18 Nov 2016 18:25:44 +0800 Subject: [PATCH] Use -Dnet.filebot.gio.GVFS="$XDG_RUNTIME_DIR/gvfs" for sandboxed snappy app but default to libgio for standard Linux environments --- installer/snappy/filebot/filebot.sh | 2 +- source/net/filebot/gio/GVFS.java | 4 +++- source/net/filebot/gio/PlatformGVFS.java | 11 ++++++----- 3 files changed, 10 insertions(+), 7 deletions(-) diff --git a/installer/snappy/filebot/filebot.sh b/installer/snappy/filebot/filebot.sh index 574b7ba5..f3eebde1 100755 --- a/installer/snappy/filebot/filebot.sh +++ b/installer/snappy/filebot/filebot.sh @@ -13,4 +13,4 @@ export APP_DATA="$SNAP_USER_DATA/data" export APP_CACHE="$SNAP_USER_DATA/cache" export APP_PREFS="$SNAP_USER_DATA/prefs" -java -Duser.home="$SNAP_USER_DATA" -Djava.library.path="$LD_LIBRARY_PATH" -Djna.library.path="$LD_LIBRARY_PATH" -Dunixfs=false -DuseGVFS=true -DuseExtendedFileAttributes=true -DuseCreationDate=false -Dawt.useSystemAAFontSettings=on -Dswing.aatext=true -Djava.net.useSystemProxies=true -Dapplication.update=skip -Dapplication.deployment=snap -Dnet.filebot.UserFiles.fileChooser=JavaFX -Dapplication.dir="$APP_DATA" -Dapplication.cache="$APP_CACHE/ehcache.disk.store" -Djava.io.tmpdir="$APP_CACHE/java.io.tmpdir" -Djava.util.prefs.userRoot="$APP_PREFS/user" -Djava.util.prefs.systemRoot="$APP_PREFS/system" -Dnet.filebot.AcoustID.fpcalc="$SNAP/usr/bin/fpcalc" $JAVA_OPTS -jar "$APP_ROOT/FileBot.jar" "$@" +java -Duser.home="$SNAP_USER_DATA" -Djava.library.path="$LD_LIBRARY_PATH" -Djna.library.path="$LD_LIBRARY_PATH" -Dunixfs=false -DuseGVFS=true -DuseExtendedFileAttributes=true -DuseCreationDate=false -Dawt.useSystemAAFontSettings=on -Dswing.aatext=true -Djava.net.useSystemProxies=true -Dapplication.update=skip -Dapplication.deployment=snap -Dnet.filebot.UserFiles.fileChooser=JavaFX -Dnet.filebot.gio.GVFS="$XDG_RUNTIME_DIR/gvfs" -Dapplication.dir="$APP_DATA" -Dapplication.cache="$APP_CACHE/ehcache.disk.store" -Djava.io.tmpdir="$APP_CACHE/java.io.tmpdir" -Djava.util.prefs.userRoot="$APP_PREFS/user" -Djava.util.prefs.systemRoot="$APP_PREFS/system" -Dnet.filebot.AcoustID.fpcalc="$SNAP/usr/bin/fpcalc" $JAVA_OPTS -jar "$APP_ROOT/FileBot.jar" "$@" diff --git a/source/net/filebot/gio/GVFS.java b/source/net/filebot/gio/GVFS.java index e769145f..168c03ce 100644 --- a/source/net/filebot/gio/GVFS.java +++ b/source/net/filebot/gio/GVFS.java @@ -3,12 +3,14 @@ package net.filebot.gio; import java.io.File; import java.net.URI; +import net.filebot.util.SystemProperty; + public interface GVFS { File getPathForURI(URI uri); public static GVFS getDefaultVFS() { - return new PlatformGVFS(); + return SystemProperty.of("net.filebot.gio.GVFS", PlatformGVFS::new, NativeGVFS::new).get(); } } diff --git a/source/net/filebot/gio/PlatformGVFS.java b/source/net/filebot/gio/PlatformGVFS.java index 3b09e45d..cd4eb8e3 100644 --- a/source/net/filebot/gio/PlatformGVFS.java +++ b/source/net/filebot/gio/PlatformGVFS.java @@ -4,12 +4,13 @@ package net.filebot.gio; import java.io.File; import java.net.URI; -import com.sun.jna.Native; - public class PlatformGVFS implements GVFS { - private static final LibC lib_c = (LibC) Native.loadLibrary("c", LibC.class); - private static final String gvfs = "/run/user/" + lib_c.getuid() + "/gvfs/"; + private final File gvfs; + + public PlatformGVFS(String gvfs) { + this.gvfs = new File(gvfs); + } public File getPathForURI(URI uri) { // e.g. smb://10.0.1.5/data/Movies/Avatar.mp4 -> /run/user/1000/gvfs/smb-share:server=10.0.1.5,share=data/Movies/Avatar.mp4 @@ -18,7 +19,7 @@ public class PlatformGVFS implements GVFS { case "file": return new File(uri); default: - return new File(gvfs + uri.getScheme() + "-share:server=" + uri.getHost() + ",share=" + uri.getPath().substring(1)); + return new File(gvfs, uri.getScheme() + "-share:server=" + uri.getHost() + ",share=" + uri.getPath().substring(1)); } }