mirror of
https://github.com/mitb-archive/filebot
synced 2024-12-24 08:48:51 -05:00
* hot fix for Folder Drop / Link Drop regression bug
@see http://www.filebot.net/forums/viewtopic.php?f=6&t=2054&p=11854#p11852
This commit is contained in:
parent
e20425e978
commit
5485004130
@ -52,7 +52,7 @@ class FileTreeTransferablePolicy extends BackgroundFileTransferablePolicy<TreeNo
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void load(List<File> files) {
|
||||
protected void load(List<File> files, TransferAction action) {
|
||||
try {
|
||||
if (files.size() > 1 || containsOnly(files, FILES)) {
|
||||
files = Arrays.asList(files.get(0).getParentFile());
|
||||
|
@ -33,7 +33,7 @@ class FileListTransferablePolicy extends FileTransferablePolicy {
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void load(List<File> files) throws IOException {
|
||||
protected void load(List<File> files, TransferAction action) throws IOException {
|
||||
// set title based on parent folder of first file
|
||||
list.setTitle(FileUtilities.getFolderName(files.get(0).getParentFile()));
|
||||
|
||||
|
@ -3,7 +3,6 @@ package net.filebot.ui.rename;
|
||||
import static java.util.Arrays.*;
|
||||
import static net.filebot.MediaTypes.*;
|
||||
import static net.filebot.ui.NotificationLogging.*;
|
||||
import static net.filebot.ui.transfer.FileTransferable.*;
|
||||
import static net.filebot.util.FileUtilities.*;
|
||||
|
||||
import java.awt.datatransfer.Transferable;
|
||||
@ -40,19 +39,16 @@ class FilesListTransferablePolicy extends BackgroundFileTransferablePolicy<File>
|
||||
|
||||
@Override
|
||||
public void handleTransferable(Transferable tr, TransferAction action) throws Exception {
|
||||
if (action == TransferAction.LINK) {
|
||||
// special handling for do-not-resolve-folders-drop
|
||||
if (action == TransferAction.LINK || action == TransferAction.PUT) {
|
||||
clear();
|
||||
load(getFilesFromTransferable(tr), false);
|
||||
} else {
|
||||
// load files recursively by default
|
||||
super.handleTransferable(tr, action);
|
||||
}
|
||||
|
||||
super.handleTransferable(tr, action);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void load(List<File> files) {
|
||||
load(files, true);
|
||||
protected void load(List<File> files, TransferAction action) {
|
||||
load(files, action != TransferAction.LINK);
|
||||
}
|
||||
|
||||
protected void load(List<File> files, boolean recursive) {
|
||||
@ -111,7 +107,7 @@ class FilesListTransferablePolicy extends BackgroundFileTransferablePolicy<File>
|
||||
|
||||
@Override
|
||||
protected void process(List<File> chunks) {
|
||||
model.addAll(FastFile.create(chunks));
|
||||
model.addAll(chunks);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -614,7 +614,7 @@ class HistoryDialog extends JDialog {
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void load(List<File> files) throws IOException {
|
||||
protected void load(List<File> files, TransferAction action) throws IOException {
|
||||
History history = getModel();
|
||||
|
||||
try {
|
||||
|
@ -61,7 +61,7 @@ class NamesListTransferablePolicy extends FileTransferablePolicy {
|
||||
model.addAll(Arrays.asList((Episode[]) tr.getTransferData((episodeArrayFlavor))));
|
||||
} else if (hasFileListFlavor(tr)) {
|
||||
// file transferable
|
||||
load(getFilesFromTransferable(tr));
|
||||
load(getFilesFromTransferable(tr), action);
|
||||
} else if (tr.isDataFlavorSupported(stringFlavor)) {
|
||||
// string transferable
|
||||
load((String) tr.getTransferData(stringFlavor));
|
||||
@ -83,7 +83,7 @@ class NamesListTransferablePolicy extends FileTransferablePolicy {
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void load(List<File> files) throws IOException {
|
||||
protected void load(List<File> files, TransferAction action) throws IOException {
|
||||
List<Object> values = new ArrayList<Object>();
|
||||
|
||||
if (containsOnly(files, LIST_FILES)) {
|
||||
|
@ -46,10 +46,11 @@ class ChecksumTableTransferablePolicy extends BackgroundFileTransferablePolicy<C
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void prepare(List<File> files) {
|
||||
protected void handleInBackground(List<File> files, TransferAction action) {
|
||||
if (files.size() == 1 && getHashType(files.get(0)) != null) {
|
||||
model.setHashType(getHashType(files.get(0)));
|
||||
}
|
||||
super.handleInBackground(files, action);
|
||||
}
|
||||
|
||||
@Override
|
||||
@ -66,7 +67,7 @@ class ChecksumTableTransferablePolicy extends BackgroundFileTransferablePolicy<C
|
||||
private final ThreadLocal<VerificationTracker> verificationTracker = new ThreadLocal<VerificationTracker>();
|
||||
|
||||
@Override
|
||||
protected void load(List<File> files) throws IOException {
|
||||
protected void load(List<File> files, TransferAction action) throws IOException {
|
||||
// initialize drop parameters
|
||||
executor.set(computationService.newExecutor());
|
||||
verificationTracker.set(new VerificationTracker(3));
|
||||
|
@ -29,14 +29,11 @@ public abstract class BackgroundFileTransferablePolicy<V> extends FileTransferab
|
||||
clear();
|
||||
}
|
||||
|
||||
prepare(files);
|
||||
|
||||
// create and start worker
|
||||
new BackgroundWorker(files).execute();
|
||||
handleInBackground(files, action);
|
||||
}
|
||||
|
||||
protected void prepare(List<File> files) {
|
||||
|
||||
protected void handleInBackground(List<File> files, TransferAction action) {
|
||||
new BackgroundWorker(files, action).execute();
|
||||
}
|
||||
|
||||
@Override
|
||||
@ -91,9 +88,11 @@ public abstract class BackgroundFileTransferablePolicy<V> extends FileTransferab
|
||||
protected class BackgroundWorker extends SwingWorker<Object, V> {
|
||||
|
||||
private final List<File> files;
|
||||
private final TransferAction action;
|
||||
|
||||
public BackgroundWorker(List<File> files) {
|
||||
public BackgroundWorker(List<File> files, TransferAction action) {
|
||||
this.files = files;
|
||||
this.action = action;
|
||||
|
||||
// register this worker
|
||||
synchronized (workers) {
|
||||
@ -109,7 +108,7 @@ public abstract class BackgroundFileTransferablePolicy<V> extends FileTransferab
|
||||
threadLocalWorker.set(this);
|
||||
|
||||
try {
|
||||
load(files);
|
||||
load(files, action);
|
||||
} finally {
|
||||
threadLocalWorker.remove();
|
||||
}
|
||||
|
@ -37,12 +37,12 @@ public abstract class FileTransferablePolicy extends TransferablePolicy {
|
||||
clear();
|
||||
}
|
||||
|
||||
load(files);
|
||||
load(files, action);
|
||||
}
|
||||
|
||||
protected abstract boolean accept(List<File> files);
|
||||
|
||||
protected abstract void load(List<File> files) throws IOException;
|
||||
protected abstract void load(List<File> files, TransferAction action) throws IOException;
|
||||
|
||||
protected abstract void clear();
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user