mirror of
https://github.com/narrrl/proton-drive-linux.git
synced 2026-11-03 16:41:26 +01:00
feat(core,fuse,gui): show how far photo locations have been read
The first timeline refresh after the Places update reads the metadata of the whole library, and until it is done the Places view has nothing to show and no sign that anything is happening. The refresh now records how many photos it has resolved out of how many, counting photos read by an earlier pass as done. Response::Places carries it as mapping (absent from older daemons, which parse as None). The Places view shows "Mapping photos: 120 of 480" with a bar while it is set, asks again every two seconds, and loads the new places once the pass ends. An empty listing during the pass says the photos are being mapped rather than that there are no places.
This commit is contained in:
1 parent
4ee2aed29b
commit
8749d6c2c6
17 files changed
+2064
-1747
No files matched your search
@@ -1462,6 +1462,14 @@ pub struct PlaceInfo {
|
||||
pub cover: PhotoItem,
|
||||
}
|
||||
|
||||
/// How many of the timeline's photos a running refresh has read the metadata
|
||||
/// (and so the location) of, out of how many. Part of [`Response::Places`].
|
||||
#[derive(Serialize, Deserialize, Debug, Clone, Copy, PartialEq, Eq)]
|
||||
pub struct MappingProgress {
|
||||
pub done: usize,
|
||||
pub total: usize,
|
||||
}
|
||||
|
||||
/// One photo in a [`Request::PhotosTimeline`] page.
|
||||
#[derive(Serialize, Deserialize, Debug, Clone)]
|
||||
pub struct PhotoItem {
|
||||
@@ -1823,8 +1831,14 @@ pub enum Response {
|
||||
/// The duplicate sets (reply to [`Request::PhotoDuplicates`]), newest
|
||||
/// first. Each set lists the copy worth keeping first.
|
||||
PhotoDuplicates { sets: Vec<Vec<PhotoItem>> },
|
||||
/// The towns the photos were taken in (reply to [`Request::PhotoPlaces`]).
|
||||
Places { items: Vec<PlaceInfo> },
|
||||
/// The towns the photos were taken in (reply to [`Request::PhotoPlaces`]),
|
||||
/// and how far a running timeline refresh has got reading photo locations
|
||||
/// — `None` when none is reading any.
|
||||
Places {
|
||||
items: Vec<PlaceInfo>,
|
||||
#[serde(default)]
|
||||
mapping: Option<MappingProgress>,
|
||||
},
|
||||
/// Thumbnails for a [`Request::PhotoThumbs`] batch.
|
||||
Thumbs { items: Vec<PhotoThumb> },
|
||||
/// Per-node outcome of a [`Request::TrashNodes`] batch. Reported per uid
|
||||
@@ -2537,12 +2551,33 @@ mod tests {
|
||||
|
||||
let line = r#"{"Places":{"items":[{"id":2950159,"name":"Berlin","country":"DE","photo_count":2,
|
||||
"cover":{"uid":"vol~b2","capture_time":1700000000,"thumb_path":null,"name":"b2.jpg","ratio":null,"no_thumb":false}}]}}"#;
|
||||
let Response::Places { items } = serde_json::from_str(line).unwrap() else {
|
||||
let Response::Places { items, mapping } = serde_json::from_str(line).unwrap() else {
|
||||
panic!("not a place listing");
|
||||
};
|
||||
assert_eq!(items.len(), 1);
|
||||
assert_eq!((items[0].id, items[0].country.as_str()), (2950159, "DE"));
|
||||
assert_eq!(items[0].cover.uid, "vol~b2");
|
||||
// A daemon from before the progress field still parses: no mapping.
|
||||
assert_eq!(mapping, None);
|
||||
|
||||
let reply = Response::Places {
|
||||
items: Vec::new(),
|
||||
mapping: Some(MappingProgress {
|
||||
done: 120,
|
||||
total: 480,
|
||||
}),
|
||||
};
|
||||
let line = serde_json::to_string(&reply).unwrap();
|
||||
let Response::Places { mapping, .. } = serde_json::from_str(&line).unwrap() else {
|
||||
panic!("not a place listing");
|
||||
};
|
||||
assert_eq!(
|
||||
mapping,
|
||||
Some(MappingProgress {
|
||||
done: 120,
|
||||
total: 480
|
||||
})
|
||||
);
|
||||
}
|
||||
|
||||
/// The sharing and devices requests must survive the same line-delimited JSON
|
||||
|
||||
Reference in new issue
Block a user