Skip to content

Commit 284c57c

Browse files
authored
feat(linux): keep stored files before a format upgrade and open .sql files (#4049)
1 parent 73da28b commit 284c57c

45 files changed

Lines changed: 2639 additions & 82 deletions

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

‎.github/workflows/build-linux.yml‎

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -409,6 +409,18 @@ jobs:
409409
# checks in every rust-format entry.
410410
- name: Check the catalogues
411411
run: meson test -C _build --no-rebuild --suite po --print-errorlogs
412+
# Reported, never failed: strings land before the translation run
413+
# after the string freeze. A release refuses the gap
414+
# (release-linux.yml, po/README.md).
415+
- name: Report untranslated entries
416+
run: |
417+
status=0
418+
po/check-complete.sh >> "$GITHUB_STEP_SUMMARY" || status=$?
419+
case "$status" in
420+
0) ;;
421+
1) echo "::warning title=Translations::a language in po/LINGUAS has untranslated or fuzzy entries, which a release refuses (linux/po/README.md)" ;;
422+
*) exit "$status" ;;
423+
esac
412424
# Translators start from this template (po/README.md), since few
413425
# distributions ship gettext 1.0 yet.
414426
- name: Publish tablepro.pot

‎.github/workflows/release-linux.yml‎

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -166,6 +166,9 @@ jobs:
166166
run: |
167167
meson setup _build --fatal-meson-warnings
168168
meson compile -C _build tablepro-pot
169+
# A language in po/LINGUAS ships complete (po/README.md).
170+
- name: Every shipped catalogue is complete
171+
run: po/check-complete.sh >> "$GITHUB_STEP_SUMMARY"
169172
- uses: actions/upload-artifact@cf430e030ddbb5b0abf93d22962f4752f3646cd9 # v7.0.2
170173
with:
171174
name: linux-pot

‎core/crates/storage/src/connections/mod.rs‎

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -814,6 +814,11 @@ impl ConnectionStore {
814814
// A connection saved with a tag deleted meanwhile drops it here.
815815
document.tidy();
816816
let bytes = crate::document::encode_document(&document)?;
817+
crate::upgrade_copies::keep_before_write_blocking::<ConnectionsDocument>(&self.inner.path)?;
818+
// Before the list itself, so a deleted connection is never gone from the list but kept in a
819+
// copy, and a failed trim leaves both as they were for the next write to try again.
820+
let kept = document.connections.iter().map(|saved| saved.id.to_string()).collect();
821+
crate::upgrade_copies::trim_connection_copies_blocking(&self.inner.path, &kept)?;
817822
crate::fs::write_private_blocking(&self.inner.path, &bytes)?;
818823
*state = StoreState::Ready(document);
819824
self.publish(state);

‎core/crates/storage/src/document.rs‎

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ use serde::de::DeserializeOwned;
55
use serde_json::Value;
66

77
use crate::document_problem::{DocumentProblem, DocumentProblemKind};
8+
use crate::error::StorageError;
89

910
/// One step of a document's upgrade chain: a file at one version
1011
/// rewritten into the shape of the next. Its `version` field is left for
@@ -97,6 +98,17 @@ fn corrupt(path: &Path, error: &serde_json::Error) -> DocumentProblem {
9798
)
9899
}
99100

101+
pub(crate) fn stored_version(bytes: &[u8]) -> Option<u32> {
102+
serde_json::from_slice::<VersionProbe>(bytes).ok()?.version
103+
}
104+
105+
// A file an older build wrote is copied aside first, and a failed copy leaves it as it was.
106+
pub fn write_document_blocking<D: VersionedDocument>(path: &Path, document: &D) -> Result<(), StorageError> {
107+
let bytes = encode_document(document)?;
108+
crate::upgrade_copies::keep_before_write_blocking::<D>(path)?;
109+
crate::fs::write_private_blocking(path, &bytes)
110+
}
111+
100112
pub fn encode_document<D: VersionedDocument>(document: &D) -> Result<Vec<u8>, serde_json::Error> {
101113
#[derive(Serialize)]
102114
struct Versioned<'a, D> {

‎core/crates/storage/src/lib.rs‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@ pub mod query_history;
2121
pub mod saved_queries;
2222
mod tag_name_error;
2323
mod unix_time;
24+
pub mod upgrade_copies;
2425

2526
pub use connection_color::ConnectionColor;
2627
pub use connection_group::ConnectionGroup;

0 commit comments

Comments
 (0)