Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions cspell.config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,7 @@ words:
- msvc
- nscloud
- oslog
- patchless
- pubspec
- repr
- reqwest
Expand Down
20 changes: 20 additions & 0 deletions library/src/c_api/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -428,6 +428,7 @@ mod test {
hash_signature: None,
}),
rolled_back_patch_numbers: None,
available_release_versions: None,
})
},
|_url, dest: &Path, _resume_from: u64| HELLO_TESTS_PATCH.write_to(dest),
Expand Down Expand Up @@ -482,6 +483,7 @@ mod test {
hash_signature: None,
}),
rolled_back_patch_numbers: None,
available_release_versions: None,
})
},
|_url, dest: &Path, _resume_from: u64| HELLO_TESTS_PATCH.write_to(dest),
Expand Down Expand Up @@ -539,6 +541,7 @@ mod test {
patch_available: false,
patch: None,
rolled_back_patch_numbers: None,
available_release_versions: None,
})
},
UNEXPECTED_DOWNLOAD,
Expand Down Expand Up @@ -623,6 +626,7 @@ mod test {
hash_signature: None,
}),
rolled_back_patch_numbers: None,
available_release_versions: None,
})
},
|_url, _dest: &Path, _resume_from: u64| Err(anyhow::anyhow!("Error")),
Expand Down Expand Up @@ -673,6 +677,7 @@ mod test {
hash_signature: None,
}),
rolled_back_patch_numbers: None,
available_release_versions: None,
})
},
|_url, dest: &Path, _resume_from: u64| HELLO_TESTS_PATCH.write_to(dest),
Expand Down Expand Up @@ -739,6 +744,7 @@ mod test {
hash_signature: None,
}),
rolled_back_patch_numbers: None,
available_release_versions: None,
})
},
|_url, dest: &Path, _resume_from: u64| HELLO_TESTS_PATCH.write_to(dest),
Expand Down Expand Up @@ -768,6 +774,8 @@ mod test {
patch_available: false,
patch: None,
rolled_back_patch_numbers: Some(vec![1]),

available_release_versions: None,
})
},
UNEXPECTED_DOWNLOAD,
Expand Down Expand Up @@ -824,6 +832,7 @@ mod test {
hash_signature: None,
}),
rolled_back_patch_numbers: None,
available_release_versions: None,
})
},
|_url, dest: &Path, _resume_from: u64| HELLO_TESTS_PATCH.write_to(dest),
Expand All @@ -846,6 +855,8 @@ mod test {
patch_available: false,
patch: None,
rolled_back_patch_numbers: Some(vec![1]),

available_release_versions: None,
})
},
UNEXPECTED_DOWNLOAD,
Expand Down Expand Up @@ -914,6 +925,7 @@ mod test {
hash_signature: None,
}),
rolled_back_patch_numbers: None,
available_release_versions: None,
})
},
|_url, dest: &Path, _resume_from: u64| HELLO_TESTS_PATCH.write_to(dest),
Expand All @@ -936,6 +948,8 @@ mod test {
patch_available: false,
patch: None,
rolled_back_patch_numbers: Some(vec![1]),

available_release_versions: None,
})
},
UNEXPECTED_DOWNLOAD,
Expand All @@ -959,6 +973,8 @@ mod test {
hash_signature: None,
}),
rolled_back_patch_numbers: Some(vec![]),

available_release_versions: None,
})
},
|_url, dest: &Path, _resume_from: u64| HELLO_TESTS_PATCH.write_to(dest),
Expand Down Expand Up @@ -1011,6 +1027,7 @@ mod test {
hash_signature: None,
}),
rolled_back_patch_numbers: None,
available_release_versions: None,
})
},
|_url, dest: &Path, _resume_from: u64| HELLO_PATCH_2_PATCH.write_to(dest),
Expand All @@ -1035,6 +1052,8 @@ mod test {
hash_signature: None,
}),
rolled_back_patch_numbers: Some(vec![2]),

available_release_versions: None,
})
},
|_url, dest: &Path, _resume_from: u64| HELLO_TESTS_PATCH.write_to(dest),
Expand Down Expand Up @@ -1123,6 +1142,7 @@ mod test {
hash_signature: None,
}),
rolled_back_patch_numbers: None,
available_release_versions: None,
})
},
UNEXPECTED_DOWNLOAD,
Expand Down
35 changes: 34 additions & 1 deletion library/src/network.rs
Original file line number Diff line number Diff line change
Expand Up @@ -262,11 +262,31 @@ impl PatchCheckRequest {
config: &UpdateConfig,
client_id: &str,
current_patch_number: Option<usize>,
) -> PatchCheckRequest {
Self::new_for_release(
config,
client_id,
&config.release_version,
current_patch_number,
)
}

/// Builds a patch-check request for an arbitrary `release_version`. Used
/// when prefetching patches for sibling releases on the same track that
/// the server advertised via `available_release_versions`. For sibling
/// fetches `current_patch_number` is always `None` — we're spoofing the
/// release_version and the server's own per-release patch number space
/// is independent of what we're running.
pub fn new_for_release(
config: &UpdateConfig,
client_id: &str,
release_version: &str,
current_patch_number: Option<usize>,
) -> PatchCheckRequest {
PatchCheckRequest {
app_id: config.app_id.clone(),
channel: config.channel.clone(),
release_version: config.release_version.clone(),
release_version: release_version.to_string(),
platform: current_platform().to_string(),
arch: current_arch().to_string(),
client_id: client_id.to_string(),
Expand Down Expand Up @@ -295,6 +315,19 @@ pub struct PatchCheckResponse {
/// uninstalled from the device and not booted from.
#[serde(default)]
pub rolled_back_patch_numbers: Option<Vec<usize>>,

/// Other release_versions on this app's track that have publishable
/// patches. The client may issue follow-up `/patches/check` requests
/// scoped to each entry to prefetch those patches before the user's
/// native binary updates to the corresponding release.
///
/// The current release_version is filtered out by the client; the server
/// may include or exclude it for convenience.
///
/// Older clients that don't recognize this field simply ignore it, so
/// it's safe for the server to populate unconditionally.
#[serde(default)]
pub available_release_versions: Option<Vec<String>>,
}

/// Reports a patch event (e.g., install success/failure) to the server.
Expand Down
Loading