Skip to content

armgit / Cap

Public Imported from GitHub
0

Open source Loom alternative. Beautiful, shareable screen recordings.

test(desktop): count the recorded length as upload metadata

Richie McIlroy175a6f0c0abe
diff --git a/apps/desktop-gpui/src/upload/verify_tests.rs b/apps/desktop-gpui/src/upload/verify_tests.rs
index 7d13956be..83a34cda7 100644
--- a/apps/desktop-gpui/src/upload/verify_tests.rs
+++ b/apps/desktop-gpui/src/upload/verify_tests.rs
@@ -214,7 +214,7 @@ struct MockState {
pub(super) struct Stats {
/// HTTP requests that reached the mock (API calls and object PUTs).
pub(super) requests: usize,
- /// PUTs of media objects and multipart parts (manifests excluded).
+ /// PUTs of media objects and multipart parts (recording metadata excluded).
pub(super) media_puts: usize,
/// PUTs of `segments/manifest.json`.
pub(super) manifest_puts: usize,
@@ -320,7 +320,7 @@ pub(super) mod budget {
/// The relaunch session only: every segment and the thumbnail once.
pub(in crate::upload) const QUEUE_RESUME_AFTER_QUIT_MID_TRANSFER: Budget =
- budget(22, 15, 2, 1_795_340, 0, 12 + POOL_RACE);
+ budget(24, 15, 2, 1_795_340, 0, 12 + POOL_RACE);
pub(in crate::upload) const QUEUE_RESUME_AFTER_QUIT_DURING_VERIFICATION: Budget =
budget(1, 0, 0, 0, 0, 1);
}
@@ -489,8 +489,7 @@ impl MockCap {
pub(super) fn stats(&self) -> Stats {
let state = self.lock();
let is_media = |path: &str| {
- path.starts_with("/s3mp/")
- || (path.starts_with("/s3/") && !path.ends_with("/manifest.json"))
+ path.starts_with("/s3mp/") || (path.starts_with("/s3/") && !is_metadata_object(path))
};
Stats {
requests: state.requests.len(),
@@ -606,7 +605,7 @@ impl Server {
.unwrap_or(0);
let media = head.method == "PUT"
&& (head.path.starts_with("/s3mp/")
- || (head.path.starts_with("/s3/") && !head.path.ends_with("/manifest.json")));
+ || (head.path.starts_with("/s3/") && !is_metadata_object(&head.path)));
let fault = self.take_fault(&head.method, &head.path);
let cut = match fault {
Some(Fault::Reset(at) | Fault::Outage(at, _) | Fault::Trip(at)) => {
@@ -936,11 +935,15 @@ impl Server {
}
}
+fn is_metadata_object(path: &str) -> bool {
+ path.ends_with("/manifest.json") || path.ends_with("/recording.json")
+}
+
impl MockState {
fn useful_bytes(&self) -> u64 {
self.objects
.iter()
- .filter(|(key, _)| !key.ends_with("/manifest.json"))
+ .filter(|(key, _)| !is_metadata_object(key))
.map(|(_, object)| object.len() as u64)
.sum()
}