mirror of
https://github.com/mitb-archive/filebot
synced 2024-08-13 17:03:45 -04:00
List files within /Volumes as media root (sandbox seems to give access to folder listings for that)
This commit is contained in:
parent
34d779faab
commit
63fc7d80b2
@ -98,12 +98,24 @@ public class DropToUnlock extends JList<File> {
|
||||
}
|
||||
}
|
||||
|
||||
// NOTE: The app sandbox seems to allow read access to /Volumes by default
|
||||
private static final File VOLUMES_FOLDER = new File("/Volumes");
|
||||
|
||||
public static List<File> getParentFolders(Collection<File> files) {
|
||||
return files.stream().map(f -> f.isDirectory() ? f : f.getParentFile()).sorted().distinct().filter(f -> !f.exists() || isLockedFolder(f)).map(f -> {
|
||||
try {
|
||||
File file = f.getCanonicalFile();
|
||||
File root = MediaDetection.getStructureRoot(file);
|
||||
|
||||
if (VOLUMES_FOLDER.equals(root)) {
|
||||
List<File> path = listPath(file);
|
||||
|
||||
// i.e. [0] / [1] Volumes / [2] HDD
|
||||
if (path.size() >= 3) {
|
||||
return listPath(file).get(2);
|
||||
}
|
||||
}
|
||||
|
||||
// if structure root doesn't work just grab first existing parent folder
|
||||
if (root == null || root.getName().isEmpty() || root.getParentFile() == null || root.getParentFile().getName().isEmpty()) {
|
||||
for (File it : listPathTail(file, Integer.MAX_VALUE, true)) {
|
||||
@ -114,6 +126,7 @@ public class DropToUnlock extends JList<File> {
|
||||
}
|
||||
return root;
|
||||
} catch (Exception e) {
|
||||
debug.log(Level.WARNING, e, e::toString);
|
||||
return null;
|
||||
}
|
||||
}).filter(f -> f != null && !f.getName().isEmpty() && isLockedFolder(f)).sorted().distinct().collect(Collectors.toList());
|
||||
|
Loading…
Reference in New Issue
Block a user