Skip to content
Merged
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
10 changes: 7 additions & 3 deletions crates/engine/src/cmd/layer.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3126,13 +3126,17 @@ fn add_url_as_given(s: &mut Session, p: &Value) -> CmdResult {
if ["geolibreProject", "geolibreLayer", "geolibreZarr"].iter().any(|key| p.get(key).is_some()) && !s.import_completion(p) {
return Err("GeoLibre download state is internal; use project.importGeolibre".into());
}
// Marks a service's document, read and kept for `service.add`: as a download, no layer would come.
if super::plugins::fetch::is_document(p) {
return Err("\"document\" is internal to service.add: leave it out".into());
}
let url = ps(p, "url").map(str::trim).filter(|u| !u.is_empty()).ok_or("url is required")?;
// A plugin command run again once the download it left to the app was added (#1202): what
// adding it answered, as often as the run asks for it (the app downloaded and added it once).
// Answering it changes nothing (the layer is its own undo step).
let wanted = s.asked_for(p);
if s.leave_downloads
&& let Some((_, answer, added)) = s.rerun_landed.iter().find(|(asked, ..)| super::plugins::fetch::same_request(asked, &wanted))
&& let Some((answer, added)) = s.rerun_answer(&wanted)
{
s.request_only = true;
// Added to another map than the one shown now: the command's next steps would act on this
Expand All @@ -3157,10 +3161,10 @@ fn add_url_as_given(s: &mut Session, p: &Value) -> CmdResult {
if missing || added.gone(s.map()) {
return Err(format!("{url}: the layer its download added was taken away (undone) before the command ran again"));
}
if super::plugins::fetch::table_gone(answer, &s.project) {
if super::plugins::fetch::table_gone(&answer, &s.project) {
return Err(format!("{url}: the table its download added was taken away (undone) before the command ran again"));
}
return added.answer_now(s.map(), answer);
return added.answer_now(s.map(), &answer);
}
// An address read through a saved S3 connection is judged by the address it wraps; the whole
// address stays what is fetched and kept.
Expand Down
277 changes: 274 additions & 3 deletions crates/engine/src/cmd/plugin_fetch.rs

Large diffs are not rendered by default.

11 changes: 10 additions & 1 deletion crates/engine/src/cmd/plugins.rs
Original file line number Diff line number Diff line change
Expand Up @@ -567,9 +567,14 @@ impl Session {
// Restore only the original opaque authorities removed by intentional suspension.
// No JSON request can create a fresh User admission after the rollback.
let suspended_keys: Vec<u64> = suspended.iter().map(|q| q.key).collect();
if self.retry_tries < fetch::MAX_RETRIES {
let giving_up = self.retry_tries >= fetch::MAX_RETRIES;
if !giving_up {
self.restore_plugin_requests(suspended)?;
}
// A service's document is read here, once the run is kept: the app adds nothing for it,
// and with no command waiting nothing would take it.
let documents: Vec<(u64, Value)> =
requested.iter().filter(|(n, asked)| !giving_up && fetch::is_document(asked) && !self.url_waits.has(*n)).cloned().collect();
// The errors this run said stay: the next run, doing the same again, doesn't repeat them.
let earlier = self.rerun_said.len();
let said: Vec<String> = self.notices_since(mark).iter().filter(|n| n.error).map(|n| n.text.clone()).collect();
Expand All @@ -580,6 +585,10 @@ impl Session {
if let Err(e) = &res {
self.discard_plugin_requests(&suspended_keys);
self.notify(e.clone(), true);
} else {
for (n, asked) in &documents {
self.url_waits.read_document(*n, asked);
}
}
res
}
Expand Down
298 changes: 269 additions & 29 deletions crates/engine/src/cmd/service.rs

Large diffs are not rendered by default.

3 changes: 3 additions & 0 deletions crates/engine/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -834,6 +834,8 @@ pub struct Session {
/// While a plugin command runs again for its downloads: what each one asked for, and what
/// adding it answered, for its `layer.addUrl` to answer once.
pub(crate) rerun_landed: Vec<(serde_json::Value, CmdResult, cmd::plugins::fetch::Added)>,
/// Which of those are failures already told in this run (see [`Session::rerun_answer`]).
pub(crate) rerun_told: Vec<usize>,
/// While a plugin command runs again: the errors its earlier runs said, not said again.
pub(crate) rerun_said: Vec<String>,
/// While plugin commands whose downloads are in run again: the downloads they wait for, still
Expand Down Expand Up @@ -1153,6 +1155,7 @@ impl Session {
next_request: 0,
call_requests: None,
rerun_landed: Vec::new(),
rerun_told: Vec::new(),
rerun_said: Vec::new(),
rerun_requests: Vec::new(),
retry_tries: 0,
Expand Down
Loading
Loading