Skip to content
15 changes: 12 additions & 3 deletions crates/engine/src/cmd/items.rs
Original file line number Diff line number Diff line change
Expand Up @@ -846,6 +846,8 @@ fn package_project(s: &mut Session, notes: &mut rustgis_data::loss::Notes) -> Re
}
// Offline areas are maps too, and their copies keep a streamed layer's source and the tiles.
let linked = left_linked("Package Project", p.maps.iter().chain(p.offline_areas.iter().map(|a| &a.data)));
// What documents read from the internet named stays held there when the package is read.
p.mark_internet_only().say(s);

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nit, grouped: the held-layer notices here, at item_output's map and layer branches (around lines 1838 and 1845), and at the template branch (around 1872) are said before the bytes are written. If the write or the size check then fails, the notice still says the layers "were written". Say them after durable_bytes_with / json_within succeeds, or reword them to "will be written".

Category: quality

let name = p.name.clone();
let readme = format!("{} — a RustGIS project package.\nOpen it with RustGIS (Project › Open), or unzip it for {}.rgis.\n", name, name);
// The package as unzipped, the README with it, within what a zip and a project may hold.
Expand Down Expand Up @@ -924,9 +926,11 @@ fn package_map(s: &mut Session, mobile: bool, tol: f64, linked: &mut rustgis_dat
crate::project::ensure_map_imports_complete(&m)?;
// After mobile_map: a hidden layer it drops isn't in the package.
linked.extend(left_linked("Package Map", [&m]));
let held = crate::project::mark_internet_only(&mut m);
let name = m.name.clone();
// With the map file's header, so an older reader refuses what it can't draw.
let (bytes, report) = crate::durable::output_owned(m, crate::project::map_file_bytes)?;
let (bytes, mut report) = crate::durable::output_owned(m, crate::project::map_file_bytes)?;
held.report(&mut report);
crate::durable::notify(s, &report);
let kind = if mobile { "mobile map package" } else { "map package" };
let readme = format!("{} — a RustGIS {kind}.\nAdd it to a project with Data › Import.\n", name);
Expand Down Expand Up @@ -1829,7 +1833,9 @@ pub fn item_output(s: &mut Session, kind: &str, p: &Value) -> Result<(String, Ve
"map" => {
let map = saved_map(s, p)?;
crate::project::ensure_map_imports_complete(map)?;
let map = embedded_map(map, &mut MAX_EMBED.clone());
let mut map = embedded_map(map, &mut MAX_EMBED.clone());
// What documents read from the internet named stays held there when the file is read.
crate::project::mark_internet_only(&mut map).say(s);
let name = map.name.clone();
(name, durable_bytes_with(s, map, crate::project::map_file_bytes)?)
}
Expand All @@ -1839,7 +1845,8 @@ pub fn item_output(s: &mut Session, kind: &str, p: &Value) -> Result<(String, Ve
if l.dataset.source.as_deref().is_some_and(|source| source.starts_with("geolibre-pending:")) {
return Err("this layer is still downloading; wait for it to finish before saving".into());
}
let layer = embed_layer(l, &mut MAX_EMBED.clone());
let mut layer = embed_layer(l, &mut MAX_EMBED.clone());
crate::project::mark_layer_internet_only(&mut layer).say(s);
let name = layer.name.clone();
(name, durable_bytes_with(s, layer, crate::project::layer_file_bytes)?)
}
Expand All @@ -1861,6 +1868,8 @@ pub fn item_output(s: &mut Session, kind: &str, p: &Value) -> Result<(String, Ve
if let Some(n) = ps(p, "name").map(str::trim).filter(|n| !n.is_empty()) {
t.name = super::within("name", "a template's name", n, 200)?;
}
// What documents read from the internet named stays held there when it is used.
t.mark_internet_only().say(s);
let name = t.name.clone();
let bytes = durable_bytes(s, t)?;
if source_references > 0 {
Expand Down
9 changes: 9 additions & 0 deletions crates/engine/src/cmd/layer.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4568,6 +4568,15 @@ pub(crate) fn add_layer_text(s: &mut Session, text: &str) -> CmdResult {
// A binding in a file is no authority to use a login here.
crate::s3_connections::clear_bindings(layer.addresses_mut());
crate::project::clear_login_bindings(layer.addresses_mut());
// A layer whose addresses a document read from the internet named is held there again before
// it is read (the repair below reads it).
if layer.internet_only {
let full = crate::render::rustgis_tiles::cache::public_restrictions_full();
crate::project::apply_layer_internet_only(&layer);
if !full && crate::render::rustgis_tiles::cache::public_restrictions_full() {
s.notify(crate::project::held_full_notice(&format!("the layer '{}'", layer.name)), false);
}
}
// A fresh id and a unique name in this map; the rest goes through project repair.
let base = layer.name.clone();
let mut i = 1;
Expand Down
2 changes: 2 additions & 0 deletions crates/engine/src/cmd/tiles.rs
Original file line number Diff line number Diff line change
Expand Up @@ -760,6 +760,8 @@ pub(crate) fn cog_tiles_to_rasters(m: &mut rustgis_map::Map) {
// anonymous plugin command added takes no saved login, as before.
l.connection = t.connection.clone();
l.anonymous = t.anonymous;
// Held to the internet, as the tile layer was.
l.internet_only = t.internet_only;
}
// Just over the layer it was drawn over, in its group; under them all without one.
let group = t.over.and_then(|o| m.group_of(o).map(|g| g.id));
Expand Down
9 changes: 9 additions & 0 deletions crates/engine/src/cmd/workspace.rs
Original file line number Diff line number Diff line change
Expand Up @@ -386,6 +386,12 @@ pub fn commands() -> Vec<C> {
s.project.active_map = i;
} else {
let mut m = a.data.clone();
// Its layers that documents read from the internet named are held there again
// before anything of the map is read.
let full = crate::render::rustgis_tiles::cache::public_restrictions_full();
crate::project::apply_internet_only(&m);
let filled = !full && crate::render::rustgis_tiles::cache::public_restrictions_full();
let area_name = a.name.clone();
let map_name = offline_map_name(&a.name);
let taken = |n: &str| s.project.maps.iter().any(|m| m.name.eq_ignore_ascii_case(n));
m.name = if taken(&map_name) { super::numbered(&map_name, taken) } else { map_name.clone() };
Expand All @@ -407,6 +413,9 @@ pub fn commands() -> Vec<C> {
}
s.project.maps.push(m);
s.project.active_map = s.project.maps.len() - 1;
if filled {
s.notify(crate::project::held_full_notice(&format!("the offline map '{area_name}'")), false);
}
}
s.active_layer = s.map().layers.first().map(|l| l.id);
s.zoom_to(&extent);
Expand Down
10 changes: 10 additions & 0 deletions crates/engine/src/durable.rs
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,12 @@ pub struct Report {
pub(crate) numbers: u32,
/// First affected dataset names; the total count still covers every dataset.
pub(crate) number_places: Vec<crate::notice_text::NoticeText>,
/// Layers held to the internet only because the session's record of such addresses is full,
/// written without the hold ([`crate::project::HELD_UNMARKED`]).
pub(crate) held_unmarked: u32,
/// Layers written held to the internet as a whole though the user named some of their
/// addresses ([`crate::project::NAMED_HELD`]).
pub(crate) named_held: u32,
}

impl Report {
Expand Down Expand Up @@ -72,6 +78,8 @@ impl Report {
(self.not_retained, "address(es) exceeded the bridge retention limit; their keys will not survive a round trip"),
(self.lost, "address(es) lost their keys when a peer sent back its project; add them again in the receiving session"),
(self.reconnect, "database source(s) from a peer require an explicit reconnect before reading"),
(self.held_unmarked, crate::project::HELD_UNMARKED),
(self.named_held, crate::project::NAMED_HELD),
(
self.executable_changes,
"credential-bearing executable field(s) changed when a peer sent back its project; supply missing values before replay",
Expand Down Expand Up @@ -119,6 +127,8 @@ impl Report {
self.executable_changes = self.executable_changes.saturating_add(other.executable_changes);
self.reconnect = self.reconnect.saturating_add(other.reconnect);
self.numbers = self.numbers.saturating_add(other.numbers);
self.held_unmarked = self.held_unmarked.saturating_add(other.held_unmarked);
self.named_held = self.named_held.saturating_add(other.named_held);
for place in &other.number_places {
if self.number_places.len() < 3 && !self.number_places.contains(place) {
self.number_places.push(place.clone());
Expand Down
Loading
Loading