-
Notifications
You must be signed in to change notification settings - Fork 5
Open
Labels
enhancementNew feature or requestNew feature or request
Description
Problem
Currently, when scanning directories during inventory, if an exception is thrown when accessing a directory (e.g., UnauthorizedAccessException when accessing protected system directories like C:\Windows, the entire inventory process fails and stops.
This prevents the inventory from completing even though other accessible directories could still be scanned. In a typical use case, users should be able to inventory directories like C:\Windows\ without administrator privileges, skipping inaccessible subdirectories.
Current Behavior
- When
DirectoryInfo.GetDirectories()orGetFiles()encounters an inaccessible directory/file, exceptions (UnauthorizedAccessException,DirectoryNotFoundException, orIOException) are thrown - The exception propagates up and causes the entire inventory to fail
- All inventory parts are aborted, even if other paths are accessible
Expected Behavior
The inventory should continue scanning accessible directories while:
- Logging inaccessible directories as warnings (without stopping the inventory)
- Tracking inaccessible directories in the inventory data structure so they are marked and excluded from synchronization operations
- Handling multiple exception types: UnauthorizedAccessException, DirectoryNotFoundException, and IOException
This ensures that:
- The inventory completes successfully for all accessible paths
- Inaccessible directories are explicitly recorded and will be skipped during synchronization
- No incomplete or failed inventories occur due to permission issues
Technical Details
- Location:
InventoryBuilder.DoAnalyze()method (lines 268 and 288) - Exceptions to handle:
System.UnauthorizedAccessExceptionSystem.IO.DirectoryNotFoundExceptionSystem.IO.IOException
- Affected operations:
DirectoryInfo.GetDirectories()andGetFiles() - Common scenario: Scanning C:\Windows\ without administrator privileges
Implementation Notes
- Wrap
GetDirectories()andGetFiles()calls in try-catch blocks - Log exceptions as warnings (not errors) with appropriate context
- Mark inaccessible directories in the inventory structure (need to design the data model for this)
- Ensure that the synchronization workflow can identify and skip these tracked inaccessible directories
Related Code
- src/ByteSync.Client/Services/Inventories/InventoryBuilder.cs (lines 268, 288)
- src/ByteSync.Client/Services/Inventories/BaseInventoryRunner.cs
- Consider impact on \InventoryPart\ and related data models to track inaccessible paths
underwoodblogCopilot
Metadata
Metadata
Assignees
Labels
enhancementNew feature or requestNew feature or request