Skip to content

Conversation

@mxpv
Copy link
Owner

@mxpv mxpv commented Jul 14, 2025

Summary

  • Implements global cleanup policy configuration as requested in Disable cleanup for all feeds? #214
  • Changes per-feed cleanup policy to optional pointer to enable inheritance
  • Adds comprehensive fallback logic and testing

Changes Made

Configuration Structure

  • Add Cleanup *feed.Cleanup field to main Config struct
  • Change per-feed Clean Cleanup to Clean *Cleanup (pointer for optional inheritance)
  • Add fallback logic in applyDefaults() to apply global policy when feed doesn't specify its own

Implementation Details

  • Add nil check in cleanup function to handle feeds without cleanup policies
  • Maintain backward compatibility - existing configurations continue to work unchanged
  • Global policy is applied only to feeds that don't specify their own cleanup policy

Documentation & Testing

  • Update config.toml.example with global cleanup configuration example
  • Add comprehensive test suite covering all inheritance scenarios:
    • Global cleanup policy inheritance by feeds without their own policy
    • No global cleanup policy scenario
    • Per-feed cleanup overriding global cleanup
  • Update existing test to handle pointer change

Usage Example

# Global cleanup policy (applies to all feeds without explicit cleanup)
[cleanup]
keep_last = 50

[feeds]
  # This feed inherits the global policy (keep_last = 50)
  [feeds.FEED1]
  url = "https://youtube.com/channel/example1"
  
  # This feed overrides the global policy
  [feeds.FEED2]
  url = "https://youtube.com/channel/example2"
  clean = { keep_last = 10 }

Test Results

✅ All existing tests pass
✅ New comprehensive test suite added
✅ Linting passes
✅ Build successful

Fixes #214

- Add global cleanup policy to main Config struct
- Change per-feed cleanup policy to pointer for optional inheritance
- Implement fallback logic to use global policy when feed doesn't specify its own
- Add comprehensive tests for cleanup policy inheritance scenarios
- Update configuration documentation with examples
- Add nil check in cleanup function to handle feeds without cleanup policies

Fixes #214
@mxpv mxpv merged commit d8e7ae7 into main Jul 14, 2025
5 checks passed
@mxpv mxpv deleted the feature/global-cleanup-policy branch July 14, 2025 23:42
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Disable cleanup for all feeds?

2 participants