From e1379dabb3da8409782ec0d6d284cd2676644a18 Mon Sep 17 00:00:00 2001 From: Reinhard Pointner Date: Mon, 11 Aug 2014 09:55:44 +0000 Subject: [PATCH] * avoid potential sandbox permission issues --- build.xml | 2 ++ source/net/filebot/mac/DropToUnlock.java | 2 +- source/net/filebot/ui/rename/FormatDialog.java | 2 +- .../net/filebot/ui/rename/HistoryDialog.java | 2 +- source/net/filebot/ui/rename/RenameAction.java | 2 +- source/net/filebot/ui/rename/RenamePanel.java | 18 +++++++++++++----- 6 files changed, 19 insertions(+), 9 deletions(-) diff --git a/build.xml b/build.xml index dc7f6e7e..be82b910 100644 --- a/build.xml +++ b/build.xml @@ -301,6 +301,8 @@ + + diff --git a/source/net/filebot/mac/DropToUnlock.java b/source/net/filebot/mac/DropToUnlock.java index 3624ce5d..e08caa56 100644 --- a/source/net/filebot/mac/DropToUnlock.java +++ b/source/net/filebot/mac/DropToUnlock.java @@ -106,7 +106,7 @@ public class DropToUnlock extends JList { }).filter(f -> f != null && isLockedFolder(f)).sorted().distinct().collect(Collectors.toList()); } - public static boolean showUnlockDialog(Window owner, Collection files) { + public static boolean showUnlockFoldersDialog(Window owner, Collection files) { final List model = getParentFolders(files); // immediately return if there is nothing that needs to be unlocked diff --git a/source/net/filebot/ui/rename/FormatDialog.java b/source/net/filebot/ui/rename/FormatDialog.java index 6cd31b75..522ad23e 100644 --- a/source/net/filebot/ui/rename/FormatDialog.java +++ b/source/net/filebot/ui/rename/FormatDialog.java @@ -208,7 +208,7 @@ public class FormatDialog extends JDialog { public void propertyChange(PropertyChangeEvent evt) { if (isMacSandbox()) { if (sample != null && sample.getMediaFile() != null && sample.getMediaFile().exists()) { - DropToUnlock.showUnlockDialog(getWindow(evt.getSource()), singleton(sample.getMediaFile())); + DropToUnlock.showUnlockFoldersDialog(getWindow(evt.getSource()), singleton(sample.getMediaFile())); } } checkFormatInBackground(); diff --git a/source/net/filebot/ui/rename/HistoryDialog.java b/source/net/filebot/ui/rename/HistoryDialog.java index 9f43b56e..72371dee 100644 --- a/source/net/filebot/ui/rename/HistoryDialog.java +++ b/source/net/filebot/ui/rename/HistoryDialog.java @@ -533,7 +533,7 @@ class HistoryDialog extends JDialog { private void rename(File directory, List elements) { Map renamePlan = getRenameMap(directory); if (isMacSandbox()) { - if (!DropToUnlock.showUnlockDialog(parent(), Stream.of(renamePlan.keySet(), renamePlan.values()).flatMap(c -> c.stream()).collect(Collectors.toList()))) { + if (!DropToUnlock.showUnlockFoldersDialog(parent(), Stream.of(renamePlan.keySet(), renamePlan.values()).flatMap(c -> c.stream()).collect(Collectors.toList()))) { return; } } diff --git a/source/net/filebot/ui/rename/RenameAction.java b/source/net/filebot/ui/rename/RenameAction.java index 2a89321f..22ea7bad 100644 --- a/source/net/filebot/ui/rename/RenameAction.java +++ b/source/net/filebot/ui/rename/RenameAction.java @@ -155,7 +155,7 @@ class RenameAction extends AbstractAction { private Map checkRenamePlan(List> renamePlan, Window parent) throws IOException { // ask for user permissions to output paths if (isMacSandbox()) { - if (!DropToUnlock.showUnlockDialog(parent, renamePlan.stream().flatMap(e -> Stream.of(e.getValue(), e.getKey())).map(f -> new File(f.getAbsolutePath())).collect(Collectors.toList()))) { + if (!DropToUnlock.showUnlockFoldersDialog(parent, renamePlan.stream().flatMap(e -> Stream.of(e.getValue(), e.getKey())).map(f -> new File(f.getAbsolutePath())).collect(Collectors.toList()))) { return emptyMap(); } } diff --git a/source/net/filebot/ui/rename/RenamePanel.java b/source/net/filebot/ui/rename/RenamePanel.java index b06a84f4..24deabf9 100644 --- a/source/net/filebot/ui/rename/RenamePanel.java +++ b/source/net/filebot/ui/rename/RenamePanel.java @@ -4,6 +4,7 @@ import static java.awt.event.KeyEvent.*; import static javax.swing.JOptionPane.*; import static javax.swing.KeyStroke.*; import static javax.swing.SwingUtilities.*; +import static net.filebot.Settings.*; import static net.filebot.ui.NotificationLogging.*; import static net.filebot.util.ExceptionUtilities.*; import static net.filebot.util.ui.LoadingOverlayPane.*; @@ -54,6 +55,7 @@ import net.filebot.StandardRenameAction; import net.filebot.UserFiles; import net.filebot.WebServices; import net.filebot.format.MediaBindingBean; +import net.filebot.mac.DropToUnlock; import net.filebot.media.MediaDetection; import net.filebot.similarity.Match; import net.filebot.ui.rename.FormatDialog.Mode; @@ -628,12 +630,18 @@ public class RenamePanel extends JComponent { // clear names list renameModel.values().clear(); - SwingWorker>, Void> worker = new SwingWorker>, Void>() { + final List remainingFiles = new LinkedList(renameModel.files()); + final SortOrder order = SortOrder.forName(persistentPreferredEpisodeOrder.getValue()); + final Locale locale = new Locale(persistentPreferredLanguage.getValue()); + final boolean autodetection = !isShiftOrAltDown(evt); // skip name auto-detection if SHIFT is pressed - private final List remainingFiles = new LinkedList(renameModel.files()); - private final SortOrder order = SortOrder.forName(persistentPreferredEpisodeOrder.getValue()); - private final Locale locale = new Locale(persistentPreferredLanguage.getValue()); - private final boolean autodetection = !isShiftOrAltDown(evt); // skip name auto-detection if SHIFT is pressed + if (isMacSandbox()) { + if (!DropToUnlock.showUnlockFoldersDialog(getWindow(RenamePanel.this), remainingFiles)) { + return; + } + } + + SwingWorker>, Void> worker = new SwingWorker>, Void>() { @Override protected List> doInBackground() throws Exception {