* make sure each filebot instance gets it's own locked ehcache dir
This commit is contained in:
parent
01d7650e9b
commit
ae6a2cb0ae
|
@ -1,2 +1,2 @@
|
||||||
#!/bin/bash
|
#!/bin/bash
|
||||||
java -Dunixfs=false -Xmx256m -Dapplication.deployment=deb -Dapplication.dir=$HOME/.filebot -Djava.io.tmpdir=$HOME/.filebot/temp -Djna.library.path=/usr/share/filebot -Djava.library.path=/usr/share/filebot -Dsun.net.client.defaultConnectTimeout=5000 -Dsun.net.client.defaultReadTimeout=25000 -jar /usr/share/filebot/FileBot.jar "$@"
|
java -Dunixfs=false -Xmx256m -Dapplication.deployment=deb -Dapplication.dir=$HOME/.filebot -Djava.io.tmpdir=$HOME/.filebot/.temp -Djna.library.path=/usr/share/filebot -Djava.library.path=/usr/share/filebot -Dsun.net.client.defaultConnectTimeout=5000 -Dsun.net.client.defaultReadTimeout=25000 -jar /usr/share/filebot/FileBot.jar "$@"
|
||||||
|
|
|
@ -1,2 +1,2 @@
|
||||||
#!/bin/bash
|
#!/bin/bash
|
||||||
java -Dunixfs=false -Dapplication.deployment=ipkg -Dapplication.dir=$HOME/.filebot -Djava.io.tmpdir=$HOME/.filebot/temp -Djna.library.path=/usr/share/filebot -Djava.library.path=/usr/share/filebot -Dsun.net.client.defaultConnectTimeout=5000 -Dsun.net.client.defaultReadTimeout=25000 -jar /usr/share/filebot/FileBot.jar "$@"
|
java -Dunixfs=false -Dapplication.deployment=ipkg -Dapplication.dir=$HOME/.filebot -Djava.io.tmpdir=$HOME/.filebot/.temp -Djna.library.path=/usr/share/filebot -Djava.library.path=/usr/share/filebot -Dsun.net.client.defaultConnectTimeout=5000 -Dsun.net.client.defaultReadTimeout=25000 -jar /usr/share/filebot/FileBot.jar "$@"
|
||||||
|
|
|
@ -21,7 +21,7 @@
|
||||||
-Dsun.net.client.defaultReadTimeout=25000
|
-Dsun.net.client.defaultReadTimeout=25000
|
||||||
|
|
||||||
# put all temporary files here
|
# put all temporary files here
|
||||||
-Djava.io.tmpdir="%EXEDIR%/temp"
|
-Djava.io.tmpdir="%EXEDIR%/.temp"
|
||||||
|
|
||||||
# look for native libs here
|
# look for native libs here
|
||||||
-Djna.library.path="%EXEDIR%"
|
-Djna.library.path="%EXEDIR%"
|
||||||
|
|
|
@ -3,4 +3,4 @@ SOURCE="${BASH_SOURCE[0]}"
|
||||||
while [ -h "$SOURCE" ] ; do SOURCE="$(readlink "$SOURCE")"; done
|
while [ -h "$SOURCE" ] ; do SOURCE="$(readlink "$SOURCE")"; done
|
||||||
dir_bin="$( cd -P "$( dirname "$SOURCE" )" && pwd )"
|
dir_bin="$( cd -P "$( dirname "$SOURCE" )" && pwd )"
|
||||||
|
|
||||||
java -Dunixfs=false -Xmx256m -Dapplication.deployment=portable "-Dapplication.dir=$dir_bin" "-Djava.io.tmpdir=$dir_bin/temp" "-Duser.home=$dir_bin" "-Djna.library.path=$dir_bin" "-Djava.library.path=$dir_bin" -Dsun.net.client.defaultConnectTimeout=5000 -Dsun.net.client.defaultReadTimeout=25000 -Djava.util.prefs.PreferencesFactory=net.sourceforge.tuned.prefs.FilePreferencesFactory -Dnet.sourceforge.tuned.prefs.file=prefs.properties -jar "$dir_bin/FileBot.jar" "$@"
|
java -Dunixfs=false -Xmx256m -Dapplication.deployment=portable "-Dapplication.dir=$dir_bin" "-Djava.io.tmpdir=$dir_bin/.temp" "-Duser.home=$dir_bin" "-Djna.library.path=$dir_bin" "-Djava.library.path=$dir_bin" -Dsun.net.client.defaultConnectTimeout=5000 -Dsun.net.client.defaultReadTimeout=25000 -Djava.util.prefs.PreferencesFactory=net.sourceforge.tuned.prefs.FilePreferencesFactory -Dnet.sourceforge.tuned.prefs.file=prefs.properties -jar "$dir_bin/FileBot.jar" "$@"
|
|
@ -3,7 +3,7 @@
|
||||||
<!--
|
<!--
|
||||||
Persistent disk store location
|
Persistent disk store location
|
||||||
-->
|
-->
|
||||||
<diskStore path="${ehcache.disk.store.dir}" />
|
<diskStore path="${cache.disk.store.dir}" />
|
||||||
|
|
||||||
<!--
|
<!--
|
||||||
Mandatory Default Cache configuration. These settings will be applied to caches
|
Mandatory Default Cache configuration. These settings will be applied to caches
|
||||||
|
|
|
@ -5,6 +5,7 @@ package net.sourceforge.filebot;
|
||||||
import static java.awt.GraphicsEnvironment.*;
|
import static java.awt.GraphicsEnvironment.*;
|
||||||
import static javax.swing.JFrame.*;
|
import static javax.swing.JFrame.*;
|
||||||
import static net.sourceforge.filebot.Settings.*;
|
import static net.sourceforge.filebot.Settings.*;
|
||||||
|
import static net.sourceforge.tuned.FileUtilities.*;
|
||||||
import static net.sourceforge.tuned.ui.TunedUtilities.*;
|
import static net.sourceforge.tuned.ui.TunedUtilities.*;
|
||||||
|
|
||||||
import java.awt.Desktop;
|
import java.awt.Desktop;
|
||||||
|
@ -14,8 +15,10 @@ import java.awt.event.WindowAdapter;
|
||||||
import java.awt.event.WindowEvent;
|
import java.awt.event.WindowEvent;
|
||||||
import java.io.File;
|
import java.io.File;
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
|
import java.io.RandomAccessFile;
|
||||||
import java.net.URI;
|
import java.net.URI;
|
||||||
import java.nio.ByteBuffer;
|
import java.nio.ByteBuffer;
|
||||||
|
import java.nio.channels.FileLock;
|
||||||
import java.security.CodeSource;
|
import java.security.CodeSource;
|
||||||
import java.security.Permission;
|
import java.security.Permission;
|
||||||
import java.security.PermissionCollection;
|
import java.security.PermissionCollection;
|
||||||
|
@ -86,6 +89,11 @@ public class Main {
|
||||||
if (args.clearUserData()) {
|
if (args.clearUserData()) {
|
||||||
// clear preferences and cache
|
// clear preferences and cache
|
||||||
System.out.println("Reset preferences and clear cache");
|
System.out.println("Reset preferences and clear cache");
|
||||||
|
for (File cache : getApplicationFolder().listFiles(FOLDERS)) {
|
||||||
|
if (cache.getName().startsWith(".")) {
|
||||||
|
delete(cache);
|
||||||
|
}
|
||||||
|
}
|
||||||
Settings.forPackage(Main.class).clear();
|
Settings.forPackage(Main.class).clear();
|
||||||
CacheManager.getInstance().clearAll();
|
CacheManager.getInstance().clearAll();
|
||||||
}
|
}
|
||||||
|
@ -314,15 +322,56 @@ public class Main {
|
||||||
/**
|
/**
|
||||||
* Shutdown ehcache properly, so that disk-persistent stores can actually be saved to disk
|
* Shutdown ehcache properly, so that disk-persistent stores can actually be saved to disk
|
||||||
*/
|
*/
|
||||||
private static void initializeCache() {
|
private static void initializeCache() throws Exception {
|
||||||
System.setProperty("ehcache.disk.store.dir", new File(getApplicationFolder(), "cache").getAbsolutePath());
|
// prepare cache folder for this application instance
|
||||||
Runtime.getRuntime().addShutdownHook(new Thread() {
|
File cacheRoot = new File(getApplicationFolder(), ".cache");
|
||||||
|
|
||||||
@Override
|
try {
|
||||||
public void run() {
|
for (int i = 0; true; i++) {
|
||||||
CacheManager.getInstance().shutdown();
|
File cache = new File(cacheRoot, String.format("%d", i));
|
||||||
|
if (!cache.isDirectory() && !cache.mkdirs()) {
|
||||||
|
throw new IOException("Failed to create cache dir: " + cache);
|
||||||
|
}
|
||||||
|
|
||||||
|
File lockFile = new File(cache, ".lock");
|
||||||
|
final RandomAccessFile handle = new RandomAccessFile(lockFile, "rw");
|
||||||
|
final FileLock lock = handle.getChannel().tryLock();
|
||||||
|
if (lock != null) {
|
||||||
|
// setup cache dir for ehcache
|
||||||
|
System.setProperty("cache.disk.store.dir", cache.getAbsolutePath());
|
||||||
|
|
||||||
|
// make sure to orderly shutdown cache
|
||||||
|
Runtime.getRuntime().addShutdownHook(new Thread() {
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void run() {
|
||||||
|
CacheManager.getInstance().shutdown();
|
||||||
|
try {
|
||||||
|
lock.release();
|
||||||
|
} catch (Exception e) {
|
||||||
|
Logger.getLogger(Main.class.getName()).log(Level.WARNING, e.toString());
|
||||||
|
}
|
||||||
|
try {
|
||||||
|
handle.close();
|
||||||
|
} catch (Exception e) {
|
||||||
|
Logger.getLogger(Main.class.getName()).log(Level.WARNING, e.toString());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
// cache for this application instance is successfully set up and locked
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
// try next lock file
|
||||||
|
handle.close();
|
||||||
}
|
}
|
||||||
});
|
} catch (Exception e) {
|
||||||
|
Logger.getLogger(Main.class.getName()).log(Level.WARNING, e.toString(), e);
|
||||||
|
}
|
||||||
|
|
||||||
|
// use cache root itself as fail-safe fallback
|
||||||
|
System.setProperty("cache.disk.store.dir", cacheRoot.getAbsolutePath());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -122,7 +122,7 @@ public class ArgumentProcessor {
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
// execute user script
|
// execute user script
|
||||||
System.setProperty("grape.root", new File(getApplicationFolder(), "grape").getAbsolutePath());
|
System.setProperty("grape.root", new File(getApplicationFolder(), ".grape").getAbsolutePath());
|
||||||
|
|
||||||
Bindings bindings = new SimpleBindings();
|
Bindings bindings = new SimpleBindings();
|
||||||
bindings.put("args", args.getFiles(false));
|
bindings.put("args", args.getFiles(false));
|
||||||
|
|
|
@ -101,6 +101,12 @@ public final class FileUtilities {
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
public static boolean delete(File file) {
|
||||||
|
// delete files or files
|
||||||
|
return org.apache.commons.io.FileUtils.deleteQuietly(file);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
public static byte[] readFile(File source) throws IOException {
|
public static byte[] readFile(File source) throws IOException {
|
||||||
InputStream in = new FileInputStream(source);
|
InputStream in = new FileInputStream(source);
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue