-
-
Notifications
You must be signed in to change notification settings - Fork 18
fix(#271): exclude hfs files from plugin and project discovery #273
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
WalkthroughThe changes involve modifications to the Changes
Possibly related PRs
Suggested labels
Thank you for using CodeRabbit. We offer it for free to the OSS community and would appreciate your support in helping us grow. If you find it useful, would you consider giving us a shout-out on your favorite social media? 🪧 TipsChatThere are 3 ways to chat with CodeRabbit:
Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments. CodeRabbit Commands (Invoked using PR comments)
Other keywords and placeholders
CodeRabbit Configuration File (
|
|
@coderabbitai review |
✅ Actions performedReview triggered.
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actionable comments posted: 0
🧹 Outside diff range and nitpick comments (4)
owlplug-client/src/main/java/com/owlplug/project/tasks/ProjectSyncTask.java (2)
67-73: Consider enhancing the file filtering logicThe current implementation effectively filters HFS metadata files using streams, which is a good approach. However, consider making it more robust:
- List<File> filteredFiles = baseFiles.stream() - // Filter out HFS metadata files starting with "._" - .filter(file -> !file.getName().startsWith("._")) - .toList(); + private static final String[] METADATA_FILE_PATTERNS = {"._", ".DS_Store"}; + + private boolean isNotMetadataFile(File file) { + String fileName = file.getName().toLowerCase(); + return Arrays.stream(METADATA_FILE_PATTERNS) + .noneMatch(fileName::startsWith); + } + + List<File> filteredFiles = baseFiles.stream() + .filter(this::isNotMetadataFile) + .toList();This enhancement:
- Makes the filtering case-insensitive for better cross-platform compatibility
- Allows for easy addition of other metadata file patterns
- Improves code reusability and maintainability
Line range hint
75-89: Optimize explorer instantiation and add error handlingThe current implementation creates new explorer instances for each file and lacks error handling for the explore operations.
+ AbletonProjectExplorer abletonExplorer = new AbletonProjectExplorer(); + ReaperProjectExplorer reaperExplorer = new ReaperProjectExplorer(); + for (File file : filteredFiles) { this.commitProgress(1); - AbletonProjectExplorer abletonExplorer = new AbletonProjectExplorer(); - ReaperProjectExplorer reaperExplorer = new ReaperProjectExplorer(); if (abletonExplorer.canExploreFile(file)) { this.updateMessage("Analyzing Ableton file: " + file.getAbsolutePath()); - DawProject project = abletonExplorer.explore(file); - projectDAO.save(project); + try { + DawProject project = abletonExplorer.explore(file); + projectDAO.save(project); + } catch (Exception e) { + log.error("Failed to analyze Ableton file: " + file.getAbsolutePath(), e); + } } else if (reaperExplorer.canExploreFile(file)) { this.updateMessage("Analyzing Reaper file: " + file.getAbsolutePath()); - DawProject project = reaperExplorer.explore(file); - projectDAO.save(project); + try { + DawProject project = reaperExplorer.explore(file); + projectDAO.save(project); + } catch (Exception e) { + log.error("Failed to analyze Reaper file: " + file.getAbsolutePath(), e); + } } }These changes:
- Move explorer instantiation outside the loop for better performance
- Add proper error handling to prevent task failure on individual file errors
- Log errors for debugging purposes
owlplug-client/src/main/java/com/owlplug/core/tasks/plugins/discovery/PluginFileCollector.java (2)
30-30: Remove unused import.The
Collectorsimport is not used in the code since.toList()is called directly instead ofCollectors.toList().-import java.util.stream.Collectors;
63-68: LGTM! Clean implementation of HFS file filtering.The stream-based approach to filter out HFS metadata files is clean and efficient, performing the filtering before the main processing loop.
Consider these improvements for better maintainability:
public class PluginFileCollector { + private static final String HFS_METADATA_PREFIX = "._"; private final Logger log = LoggerFactory.getLogger(this.getClass()); // ... existing code ... public List<PluginFile> collect(String directoryPath, PluginFormat pluginFormat) { // ... existing code ... List<File> filteredFiles = baseFiles.stream() // Filter out HFS metadata files (resource fork files created by macOS) // These files contain additional metadata and should not be processed as plugins - .filter(file -> !file.getName().startsWith("._")) + .filter(file -> !file.getName().startsWith(HFS_METADATA_PREFIX)) .toList();
📜 Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
📒 Files selected for processing (2)
owlplug-client/src/main/java/com/owlplug/core/tasks/plugins/discovery/PluginFileCollector.java(2 hunks)owlplug-client/src/main/java/com/owlplug/project/tasks/ProjectSyncTask.java(2 hunks)
🔇 Additional comments (3)
owlplug-client/src/main/java/com/owlplug/project/tasks/ProjectSyncTask.java (2)
Line range hint 57-66: LGTM: File collection logic is well-structured
The implementation properly handles multiple project directories and maintains a list of unique files while providing user feedback through progress messages.
67-73: Verify consistent implementation across codebase
Let's ensure the HFS metadata file filtering is implemented consistently across the codebase.
✅ Verification successful
HFS metadata filtering is consistently implemented
The filtering of HFS metadata files (starting with "._") is implemented consistently in both locations where file filtering is performed:
ProjectSyncTask.javaPluginFileCollector.java
Both implementations use the same pattern and logic for filtering out these metadata files. No other file filtering patterns were found that would need similar updates.
🏁 Scripts executed
The following scripts were executed for the analysis:
Script:
#!/bin/bash
# Search for similar file filtering implementations
rg -l "\.getName\(\)\.startsWith\(\"\._\"\)"
# Search for potential test files that might need updating
fd -e java -e groovy -e kotlin "Test.*\.(?:java|groovy|kotlin)$" --exec grep -l "ProjectSync"
Length of output: 309
Script:
#!/bin/bash
# Let's examine the implementation in PluginFileCollector.java to compare the filtering logic
rg -A 5 -B 5 "\.getName\(\)\.startsWith\(\"\._\"\)" owlplug-client/src/main/java/com/owlplug/core/tasks/plugins/discovery/PluginFileCollector.java
# Check if there are any other file filtering patterns we should be aware of
rg "\.filter\(.*file.*\)"
Length of output: 1130
owlplug-client/src/main/java/com/owlplug/core/tasks/plugins/discovery/PluginFileCollector.java (1)
63-66: Verify plugin filename patterns.
Let's ensure we're not accidentally excluding any valid plugin files with this filter.
✅ Verification successful
Based on the shell script results, I can now generate the final response:
Filter for "._" files is safe and appropriate
The verification confirms this filter is safe because:
- No actual plugin files with "._" prefix were found in the codebase
- The codebase clearly defines valid plugin extensions as:
.vst,.vst3,.dll,.component,.so,.lv2(and their.disabledvariants)
- These "._" files are indeed macOS metadata files, not actual plugins
🏁 Scripts executed
The following scripts were executed for the analysis:
Script:
#!/bin/bash
# Description: Check for any existing plugin files that start with "._" to confirm we're not excluding valid plugins
# Also analyze typical plugin filename patterns in the codebase
echo "Checking for any plugin-related files starting with '._'..."
rg -l "\.vst|\.vst3|\.dll|\.component" | while read -r file; do
basename "$file" | grep "^._"
done
echo "Analyzing typical plugin filename patterns..."
# Look for file extension patterns in code that might indicate plugin types
rg -A 2 "\.getExtension\(\)|\.endsWith\("
Length of output: 13517
No description provided.