mirror of
https://github.com/mitb-archive/filebot
synced 2025-03-10 06:20:27 -04:00
* try to make sure we always start a new cache for each update (so we don't have to worry about outdated yet cached data)
This commit is contained in:
parent
50a92d3faa
commit
bb32741af9
@ -1,3 +1,5 @@
|
|||||||
|
Invoke-Expression 'filebot -clear-cache'
|
||||||
|
|
||||||
$app = Get-WmiObject -Query "SELECT * FROM Win32_Product WHERE Name = 'FileBot'"
|
$app = Get-WmiObject -Query "SELECT * FROM Win32_Product WHERE Name = 'FileBot'"
|
||||||
echo $app
|
echo $app
|
||||||
|
|
||||||
|
@ -312,6 +312,10 @@ Section "$(Section_Name_MainProduct)" SECTIONID_MAINPRODUCT
|
|||||||
Pop $MSI_STATUS # grab return value
|
Pop $MSI_STATUS # grab return value
|
||||||
|
|
||||||
${if} $MSI_STATUS == "0"
|
${if} $MSI_STATUS == "0"
|
||||||
|
DetailPrint "Clear cache and temporary files"
|
||||||
|
nsExec::Exec `"C:\Program Files\FileBot\filebot.exe" -clear-cache`
|
||||||
|
nsExec::Exec `"C:\Program Files\FileBot\filebot.exe" -script "g:net.sourceforge.filebot.Main.warmupCachedResources()"`
|
||||||
|
|
||||||
# [OpenCandy]
|
# [OpenCandy]
|
||||||
; This section is hidden. It will always execute during installation
|
; This section is hidden. It will always execute during installation
|
||||||
; but it won't appear on your component selection screen.
|
; but it won't appear on your component selection screen.
|
||||||
@ -320,7 +324,7 @@ Section "$(Section_Name_MainProduct)" SECTIONID_MAINPRODUCT
|
|||||||
# [/OpenCandy]
|
# [/OpenCandy]
|
||||||
${else}
|
${else}
|
||||||
DetailPrint "msiexec error $MSI_STATUS"
|
DetailPrint "msiexec error $MSI_STATUS"
|
||||||
DetailPrint "Install failed."
|
DetailPrint "Install failed. Please download the .msi package manually."
|
||||||
Abort
|
Abort
|
||||||
${endif}
|
${endif}
|
||||||
SectionEnd
|
SectionEnd
|
||||||
|
@ -23,6 +23,7 @@ import java.nio.ByteBuffer;
|
|||||||
import java.nio.channels.Channels;
|
import java.nio.channels.Channels;
|
||||||
import java.nio.channels.FileChannel;
|
import java.nio.channels.FileChannel;
|
||||||
import java.nio.channels.FileLock;
|
import java.nio.channels.FileLock;
|
||||||
|
import java.nio.charset.Charset;
|
||||||
import java.security.CodeSource;
|
import java.security.CodeSource;
|
||||||
import java.security.Permission;
|
import java.security.Permission;
|
||||||
import java.security.PermissionCollection;
|
import java.security.PermissionCollection;
|
||||||
@ -34,6 +35,7 @@ import java.util.Collections;
|
|||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Locale;
|
import java.util.Locale;
|
||||||
import java.util.Properties;
|
import java.util.Properties;
|
||||||
|
import java.util.Scanner;
|
||||||
import java.util.logging.Level;
|
import java.util.logging.Level;
|
||||||
import java.util.logging.Logger;
|
import java.util.logging.Logger;
|
||||||
|
|
||||||
@ -458,13 +460,38 @@ public class Main {
|
|||||||
throw new IOException("Failed to create cache dir: " + cache);
|
throw new IOException("Failed to create cache dir: " + cache);
|
||||||
}
|
}
|
||||||
|
|
||||||
File lockFile = new File(cache, ".lock");
|
final File lockFile = new File(cache, ".lock");
|
||||||
final RandomAccessFile handle = new RandomAccessFile(lockFile, "rw");
|
final RandomAccessFile handle = new RandomAccessFile(lockFile, "rw");
|
||||||
final FileLock lock = handle.getChannel().tryLock();
|
final FileChannel channel = handle.getChannel();
|
||||||
|
final FileLock lock = channel.tryLock();
|
||||||
if (lock != null) {
|
if (lock != null) {
|
||||||
// setup cache dir for ehcache
|
// setup cache dir for ehcache
|
||||||
System.setProperty("ehcache.disk.store.dir", cache.getAbsolutePath());
|
System.setProperty("ehcache.disk.store.dir", cache.getAbsolutePath());
|
||||||
|
|
||||||
|
int applicationRevision = getApplicationRevisionNumber();
|
||||||
|
int cacheRevision = 0;
|
||||||
|
try {
|
||||||
|
cacheRevision = new Scanner(channel, "UTF-8").nextInt();
|
||||||
|
} catch (Exception e) {
|
||||||
|
// ignore
|
||||||
|
}
|
||||||
|
|
||||||
|
if (cacheRevision != applicationRevision && applicationRevision > 0) {
|
||||||
|
System.out.format("Application (r%d) does not match cache (r%d): reset cache%n", applicationRevision, cacheRevision);
|
||||||
|
|
||||||
|
// delete all files related to previous cache instances
|
||||||
|
for (File it : cache.listFiles()) {
|
||||||
|
if (!it.equals(lockFile)) {
|
||||||
|
delete(cache);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// set new cache revision
|
||||||
|
channel.position(0);
|
||||||
|
channel.write(Charset.forName("UTF-8").encode(String.valueOf(applicationRevision)));
|
||||||
|
channel.truncate(channel.position());
|
||||||
|
}
|
||||||
|
|
||||||
// make sure to orderly shutdown cache
|
// make sure to orderly shutdown cache
|
||||||
Runtime.getRuntime().addShutdownHook(new Thread() {
|
Runtime.getRuntime().addShutdownHook(new Thread() {
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user