coven_storage/left_upload.rs
1//! An upload a device left in storage, as another device finds it in that
2//! device's upload places to end it (§17.10), or as a later detection or
3//! connection finds what a detection run left (§20.7).
4
5use crate::RequestKind;
6use coven_crypto::SecretText;
7
8/// One upload a device left: an unfinished provider session, a staged
9/// temporary, or a detection probe. Only the provider that listed it can
10/// end it.
11pub struct LeftUpload(pub(crate) Left);
12
13pub(crate) enum Left {
14 /// An unfinished S3 multipart upload: its key and native id.
15 S3Multipart { key: String, id: SecretText },
16 /// An object, or on OneDrive the whole folder, staged in the device's
17 /// reserved folder (D10): an S3 key, or a path under the configured
18 /// OneDrive folder.
19 Staged(String),
20 /// An S3 detection probe under its run's `.coven-check` prefix (§20.7).
21 Probe(String),
22 /// A CloudKit upload root that isn't published; deleting it deletes the
23 /// parts it owns.
24 #[cfg(target_vendor = "apple")]
25 CloudKitRoot(String),
26 /// A session of the deterministic provider.
27 #[cfg(any(test, feature = "test-utils"))]
28 Memory(u64),
29}
30
31impl LeftUpload {
32 /// The kind of request that ends it: an object's deletion, or a step of
33 /// a session.
34 pub(crate) fn request(&self) -> RequestKind {
35 match self.0 {
36 Left::Staged(_) | Left::Probe(_) => RequestKind::Delete,
37 _ => RequestKind::Upload,
38 }
39 }
40}