fix(backend): apply auto-tag rule to existing files on creation
CreateRule accepted apply_to_existing but ignored it, so enabling the checkbox while creating a rule never retroactively tagged files already carrying the when-tag — only activating an existing rule did. Extract the retroactive expansion into TagRuleRepo.ApplyToExisting (reused by SetActive) and call it from CreateRule when the rule is active, inside one transaction so a file is never left half-tagged. Mirrors SetRuleActive semantics, including following only active downstream rules. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
This commit is contained in:
@@ -101,6 +101,10 @@ type TagRuleRepo interface {
|
||||
// are both true, the full transitive expansion of thenTagID is retroactively
|
||||
// applied to all files that already carry whenTagID.
|
||||
SetActive(ctx context.Context, whenTagID, thenTagID uuid.UUID, active, applyToExisting bool) error
|
||||
// ApplyToExisting retroactively applies the full transitive expansion of
|
||||
// thenTagID (following active rules) to every file that already carries
|
||||
// whenTagID. Used when a rule is created or activated with apply_to_existing.
|
||||
ApplyToExisting(ctx context.Context, whenTagID, thenTagID uuid.UUID) error
|
||||
Delete(ctx context.Context, whenTagID, thenTagID uuid.UUID) error
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user