Skip to main content

coven/
handle_uploads.rs

1//! The upload queue as the app controls it (§17.9, E7): what it holds, an
2//! early retry, and the pause, which holds trailing uploads only (§17.4).
3use crate::*;
4
5impl CovenHandle {
6    /// Queue, pause setting and provider-confirmed session progress in one
7    /// committed database snapshot, available while disconnected, with the
8    /// files this device is sending now (E7).
9    pub async fn uploads(&self) -> CovenResult<UploadQueue> {
10        Ok(self.database.upload_queue().await?.into())
11    }
12    /// Optionally retry recoverable uploads early; provider cooldowns still
13    /// hold them and individual failures stay in pending() (§17.9). While
14    /// uploads are paused, or the network is metered and the app moves files
15    /// only on unmetered networks, it tries only bound ones, and while sync
16    /// is stopped none, saying so (§17.4, §17.9). Once the upload worker
17    /// has ended other than with the store, it fails with why (E15).
18    pub async fn retry_uploads_now(&self) -> Result<DrainOutcome, SyncError> {
19        self.files.retry_uploads_now().await
20    }
21    /// Pause trailing uploads, or resume them, in a write of its own
22    /// (`CovenWrite::set_uploads_paused`).
23    pub async fn set_uploads_paused(&self, paused: bool) -> CovenResult<()> {
24        self.write(move |write| Ok(write.set_uploads_paused(paused)?)).await
25    }
26    /// Move files only on unmetered networks, or on any, in a write of its
27    /// own (`CovenWrite::set_unmetered_only`).
28    pub async fn set_unmetered_only(&self, unmetered_only: bool) -> CovenResult<()> {
29        self.write(move |write| Ok(write.set_unmetered_only(unmetered_only)?)).await
30    }
31}
32
33#[cfg(test)]
34#[path = "handle_uploads_tests.rs"]
35mod tests;