Skip to content

# milestone patch v3.0.1 - a3 #10

Description

@aj1126

milestone patch v3.0.1 - a3

3. Infinite Categorization Nesting

File: src/MyBookTools.psm1

Function: Invoke-MyBookCategorize

Issue: Running categorization multiple times causes files to nest infinitely (e.g., moving Projects/file.txt into Projects/Projects/file.txt).

Root Cause: The logic computes relative paths from the root without checking if the file is already seated within a valid category destination.

Resolution:
Implement a guard clause to bypass files that reside within any computed destination directory.

    foreach ($file in $files) {
        # Skip if the file is already seated in a destination category directory
        $alreadyCategorized = $false
        foreach ($dest in $destinations.Values) {
            if ($file.FullName.StartsWith($dest, [System.StringComparison]::InvariantCultureIgnoreCase)) {
                $alreadyCategorized = $true
                break
            }
        }
        if ($alreadyCategorized) { continue }

        $targetCategory = $null
        # ... [rest of existing matching logic] ...

Metadata

Metadata

Assignees

Labels

bugSomething isn't working

Projects

No projects

Relationships

None yet

Development

No branches or pull requests

Issue actions