litestream icon indicating copy to clipboard operation
litestream copied to clipboard

Add file/directory watcher support for directory replication

Open corylanou opened this issue 2 months ago • 0 comments

PR #738 added directory replication functionality that allows Litestream to replicate all SQLite databases found within a directory structure. Currently, this only picks up databases that exist when Litestream starts.

The next enhancement is to add file/directory watcher support so that:

  1. New databases are automatically detected when they're created in the watched directory after Litestream has started
  2. Deleted databases are removed from replication when they're deleted from the filesystem
  3. The system automatically adapts to changes in the directory structure without requiring a restart

Implementation Considerations

  • Use appropriate file system watcher for cross-platform support (e.g., fsnotify)
  • Handle edge cases like temporary files, partially-written databases, and rapid create/delete cycles
  • Consider performance implications for directories with many databases
  • Maintain thread safety when adding/removing database monitors
  • Log clear messages when databases are added to or removed from replication

Related Work

  • PR #738 (Directory replication feature)

corylanou avatar Nov 03 '25 22:11 corylanou