Repository navigation
fix(engine): keep renamed offline maps linked to their areas #2508
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
8658661
22aaf39
0c14d6f
45e4fe5
06a029e
1cb3b0c
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -535,7 +535,21 @@ fn import_maps(s: &mut Session, p: &Value) -> CmdResult { | |
| }; | ||
| let mut names = Vec::new(); | ||
| let first_map = s.project.maps.len(); | ||
| let mut detached_offline = 0; | ||
| let mut renamed_offline = 0; | ||
| for mut m in maps.into_iter().take(MAX_IMPORTED_MAPS) { | ||
| // A map imported without its home area becomes an independent copy. | ||
| detached_offline += usize::from(m.offline_area_id.take().is_some()); | ||
| // Nor may its title make it one: an older project matches its offline copy by the name | ||
| // "<area> (offline)", and syncing an unrelated map would delete what it lacks. | ||
| let suffix = super::field::OFFLINE; | ||
| if m.name.len() > suffix.len() | ||
| && m.name.is_char_boundary(m.name.len() - suffix.len()) | ||
| && m.name[m.name.len() - suffix.len()..].eq_ignore_ascii_case(suffix) | ||
| { | ||
| m.name = format!("{} (imported)", &m.name[..m.name.len() - suffix.len()]); | ||
| renamed_offline += 1; | ||
| } | ||
| // A binding in a file is no authority to use a login here. | ||
| crate::s3_connections::clear_bindings(m.addresses_mut()); | ||
| crate::project::clear_login_bindings(m.addresses_mut()); | ||
|
|
@@ -549,6 +563,18 @@ fn import_maps(s: &mut Session, p: &Value) -> CmdResult { | |
| m.renew_instance_id(); | ||
| s.project.maps.push(m); | ||
| } | ||
| if detached_offline > 0 { | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. AGENTS.md (Never silent, "Test both ways"): the detach notice added here has no test.
Confidence: high that the gap exists (grep finds no test referencing "detached from").
Member
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Added in 45e4fe565: |
||
| s.notify( | ||
| format!("{detached_offline} imported map(s) were detached from their offline areas, which aren't imported with maps"), | ||
| false, | ||
| ); | ||
| } | ||
| if renamed_offline > 0 { | ||
| s.notify( | ||
| format!("{renamed_offline} imported map(s) titled as offline copies were renamed \"… (imported)\", so they aren't taken for this project's offline maps"), | ||
| false, | ||
| ); | ||
| } | ||
| if let Some(message) = super::design::display_area_messages(s.project.maps.iter().skip(first_map).flat_map(|map| map.layers.iter())) { | ||
| s.notify(message, false); | ||
| } | ||
|
|
@@ -747,6 +773,7 @@ fn template(p: &Project) -> (Project, TemplateLosses) { | |
| }) | ||
| .saturating_add(t.tables.iter().filter(|table| table.source.is_some()).count()); | ||
| for m in &mut t.maps { | ||
| m.offline_area_id = None; | ||
| for l in &mut m.layers { | ||
| l.dataset.features.clear(); | ||
| l.selection.clear(); | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Bug (medium confidence, about 0.6): detaching the association does not make the imported copy independent. An imported map keeps its
<area> (offline)title, andoffline_map_indexstill matches any map withoffline_area_id == Noneand that title. So if the destination project has an area with the same name and no map with that title, the imported map is adopted as the area's offline copy.offline.openthen reuses it and unbinds its table links, andoffline.synctreats its contents as the area's edits, which can delete source features the copy lacks.Suggested direction: when a detached map's title carries the offline suffix, rename it so title matching can't claim it, and say so in the same notice. Add a test: an import of such a map gives the notice and does not make
offline.openreuse it.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Fixed in 22aaf398e: an imported map titled
<area> (offline)is renamed<area> (imported)with a notice, so title matching can't adopt it.an_imported_offline_titled_map_is_not_taken_for_an_area_copyimports such a map into a project with aCrewarea and checks thatoffline.openmakes its own copy.