Skip to content

Add change detection hook to CoveEncryptedBackend #600

@praveenperera

Description

@praveenperera

Add a change_sender: Option<flume::Sender<BackupEvent>> to CoveEncryptedBackend so the cloud backup actor knows when redb files change on disk.

Hook point: sync_data() — fires after redb flushes writes (better than write() which fires many times per commit).

pub struct BackupEvent {
    pub file_path: PathBuf,
    pub timestamp: SystemTime,
}
fn sync_data(&self, _eventual: bool) -> Result<(), io::Error> {
    self.file.sync_data()?;
    if let Some(sender) = &self.change_sender {
        let _ = sender.try_send(BackupEvent {
            file_path: self.path.clone(),
            timestamp: SystemTime::now(),
        });
    }
    Ok(())
}

A single global flume::Sender<BackupEvent> is shared by all CoveEncryptedBackend instances (set up during open_or_create_database()). The receiver feeds the CloudBackupActor.

Risk: redb may call sync_data() multiple times per transaction commit — debounce in the actor handles this, but worth verifying the call pattern doesn't create excessive channel traffic.

Files: rust/src/database/encrypted_backend.rs, rust/src/database.rs

Metadata

Metadata

Assignees

No one assigned

    Labels

    cspp:phase:5CSPP Phase 5: Explicit redb Cloud Upload + Startup Sync

    Type

    No type

    Projects

    Status

    Done

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions