Skip to main content

coven/
handle_discarded_devices.rs

1//! Deleting the installations resets kept, at the app's request (§19.3, E5).
2
3use crate::*;
4
5impl CovenHandle {
6    /// Delete the installations `reset_device` kept in this store's directory,
7    /// each moved aside when its reset swapped it out (§19.3). Nothing reads
8    /// them once the reset's notice is in the database, and the store's own
9    /// files stay. Returns once they are gone and the directory is synced. A
10    /// failure midway returns its error and leaves the rest, part of one
11    /// perhaps, for the next call, which removes what remains; with none left
12    /// it succeeds.
13    pub async fn delete_discarded_devices(&self) -> CovenResult<()> {
14        let directory = self.directory.clone();
15        let result = crate::task::blocking("delete the discarded devices", move || {
16            directory.delete_discarded_devices()
17        })
18        .await;
19        // Whatever it removed before a failure changes what the store keeps.
20        self.database.local_bytes_changed();
21        result??;
22        Ok(())
23    }
24}
25
26#[cfg(test)]
27#[path = "handle_discarded_devices_tests.rs"]
28mod tests;