|
22 | 22 | import com.owlplug.plugin.model.PluginFormat; |
23 | 23 | import com.owlplug.plugin.model.Symlink; |
24 | 24 | import com.owlplug.plugin.tasks.discovery.fileformats.PluginFile; |
| 25 | +import java.io.File; |
| 26 | +import java.util.ArrayList; |
| 27 | +import java.util.HashSet; |
25 | 28 | import java.util.LinkedHashSet; |
26 | 29 | import java.util.Set; |
27 | 30 |
|
@@ -66,6 +69,15 @@ public ScopedScanEntityCollector collect() { |
66 | 69 |
|
67 | 70 | collectedSymlinks.addAll(symlinkCollector.collect(parameters.getDirectoryScope())); |
68 | 71 |
|
| 72 | + // Try to restore original scan directory when a directory scope is used |
| 73 | + // https://github.com/DropSnorz/OwlPlug/issues/424 |
| 74 | + String scanPath = getScanPathFromDirectoryScope(parameters.getDirectoryScope()); |
| 75 | + if (scanPath != null) { |
| 76 | + File scanFile = new File(getScanPathFromDirectoryScope(scanPath)); |
| 77 | + collectedPluginFiles.forEach(f -> f.setScanDirectory(scanFile)); |
| 78 | + } |
| 79 | + |
| 80 | + |
69 | 81 | } else { |
70 | 82 | // Plugins are retrieved from regulars directories |
71 | 83 | String vst2Directory = parameters.getVst2Directory(); |
@@ -123,4 +135,38 @@ public Set<Symlink> getSymlinks() { |
123 | 135 | return symlinks; |
124 | 136 | } |
125 | 137 |
|
| 138 | + private Set<String> getAllPluginScanPath() { |
| 139 | + Set<String> paths = new HashSet<String>(); |
| 140 | + |
| 141 | + paths.add(parameters.getVst2Directory()); |
| 142 | + paths.add(parameters.getVst3Directory()); |
| 143 | + paths.add(parameters.getAuDirectory()); |
| 144 | + paths.add(parameters.getLv2Directory()); |
| 145 | + |
| 146 | + paths.addAll(parameters.getVst2ExtraDirectories()); |
| 147 | + paths.addAll(parameters.getVst3ExtraDirectories()); |
| 148 | + paths.addAll(parameters.getAuExtraDirectories()); |
| 149 | + paths.addAll(parameters.getLv2ExtraDirectories()); |
| 150 | + |
| 151 | + // Clean blank paths if some are provided |
| 152 | + paths.removeIf(String::isBlank); |
| 153 | + |
| 154 | + return paths; |
| 155 | + |
| 156 | + } |
| 157 | + |
| 158 | + /** |
| 159 | + * Compute original scan directory based on the provided directory scope. |
| 160 | + * See related <a href="https://github.com/DropSnorz/OwlPlug/issues/424">issue</a> |
| 161 | + * @param directoryScope the directory scope |
| 162 | + * @return path to the potential scan directory |
| 163 | + */ |
| 164 | + private String getScanPathFromDirectoryScope(String directoryScope) { |
| 165 | + return getAllPluginScanPath() |
| 166 | + .stream() |
| 167 | + .sorted() |
| 168 | + .filter(s -> directoryScope.contains(s)) |
| 169 | + .findFirst().orElse(null); |
| 170 | + } |
| 171 | + |
126 | 172 | } |
0 commit comments