mirror of
https://github.com/mitb-archive/filebot
synced 2024-12-25 09:18:51 -05:00
* better account for large history files
This commit is contained in:
parent
1c89f8c3ef
commit
f4070a4c07
@ -1,7 +1,5 @@
|
||||
|
||||
package net.sourceforge.filebot;
|
||||
|
||||
|
||||
import static net.sourceforge.filebot.Settings.*;
|
||||
|
||||
import java.io.File;
|
||||
@ -19,12 +17,10 @@ import net.sourceforge.filebot.History.Element;
|
||||
import net.sourceforge.tuned.ByteBufferInputStream;
|
||||
import net.sourceforge.tuned.ByteBufferOutputStream;
|
||||
|
||||
|
||||
public final class HistorySpooler {
|
||||
|
||||
private static final HistorySpooler instance = new HistorySpooler();
|
||||
|
||||
|
||||
public static HistorySpooler getInstance() {
|
||||
return instance;
|
||||
}
|
||||
@ -35,7 +31,6 @@ public final class HistorySpooler {
|
||||
|
||||
private History sessionHistory = new History();
|
||||
|
||||
|
||||
public synchronized History getCompleteHistory() throws IOException {
|
||||
if (!persistentHistoryEnabled || persistentHistoryFile.length() <= 0) {
|
||||
return new History();
|
||||
@ -58,7 +53,6 @@ public final class HistorySpooler {
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
public synchronized void commit() {
|
||||
if (!persistentHistoryEnabled || sessionHistory.sequences().isEmpty()) {
|
||||
return;
|
||||
@ -72,7 +66,7 @@ public final class HistorySpooler {
|
||||
FileChannel channel = f.getChannel();
|
||||
FileLock lock = channel.lock();
|
||||
try {
|
||||
ByteBufferOutputStream data = new ByteBufferOutputStream(f.length());
|
||||
ByteBufferOutputStream data = new ByteBufferOutputStream((int) (f.length() > 0 ? f.length() : 1024), 0.2f);
|
||||
int read = data.transferFully(channel);
|
||||
|
||||
History history = read > 0 ? History.importHistory(new ByteBufferInputStream(data.getByteBuffer())) : new History();
|
||||
@ -98,7 +92,6 @@ public final class HistorySpooler {
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
public synchronized void append(Iterable<Entry<File, File>> elements) {
|
||||
List<Element> sequence = new ArrayList<Element>();
|
||||
|
||||
@ -112,17 +105,14 @@ public final class HistorySpooler {
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
public History getSessionHistory() {
|
||||
return sessionHistory;
|
||||
}
|
||||
|
||||
|
||||
public int getPersistentHistoryTotalSize() {
|
||||
return persistentHistoryTotalSize;
|
||||
}
|
||||
|
||||
|
||||
public void setPersistentHistoryEnabled(boolean persistentHistoryEnabled) {
|
||||
this.persistentHistoryEnabled = persistentHistoryEnabled;
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user