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
6 changes: 6 additions & 0 deletions .git-blame-ignore-revs
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
# Commits `git blame` should look through: whole-tree mechanical changes that touch
# every line and change nothing. GitHub reads this file; locally, run once:
# git config blame.ignoreRevsFile .git-blame-ignore-revs

# Format the Rust backend with rustfmt
b0b3fe18e1d81c7ea620ac79e1e62788a22d9964
32 changes: 13 additions & 19 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -170,33 +170,27 @@ jobs:
working-directory: src-tauri
run: cargo test --verbose

# Both lint steps below are ADVISORY and named so, because this suite now decides whether
# a merge to main ships a binary and "Tests passed" must not be read as "lint passed".
# Both lints gate. They were advisory while the tree was not clean - and an advisory step
# that fails on every run is noise nobody reads, so findings piled up: by v1.9.0 clippy had
# 14 in the lib and 6 in its tests, and fmt 324 diffs, each run showing two red "exit code"
# annotations on a green pipeline. The tree is clean now, so a new finding fails the job.
#
# Neither is currently clean: `cargo clippy -- -D warnings` reports 11 findings in the lib
# and 14 in lib tests across 10 lint families (len_zero, single_match, manual_flatten,
# ptr_arg, result_large_err and friends - all cosmetic, no correctness issues), and
# `cargo fmt --check` reports 231 diffs, meaning the tree has never been rustfmt'd.
# `--all-targets` so test code is held to the same bar: without it clippy checks only the
# lib and bins, and the test findings above were never reported at all.
#
# Gating them is the right end state and it is cheap - one `cargo fmt` commit plus a pass
# over ten lint families - but it is a tree-wide reformat that would bury `git blame`, so
# it belongs in its own commit rather than riding along with a CI change. When that lands,
# drop the `continue-on-error` and the "(advisory)" from both names.
#
# One OS, not three. Neither lint is platform-dependent, and clippy's check-mode
# artifacts carry different fingerprints from the test build's - so on every leg it
# was a second near-full compile, for a result the other two legs had already given.
- name: Run Clippy (advisory, non-gating)
# One OS, not three. Both lints are mostly platform-independent, and clippy's check-mode
# artifacts carry different fingerprints from the test build's - so on every leg it was a
# second near-full compile. The price: code behind `#[cfg(target_os = "windows")]` or
# `"macos"` is not linted here. Run `cargo clippy --all-targets` locally on those.
- name: Run Clippy
if: matrix.os == 'ubuntu-latest'
working-directory: src-tauri
run: cargo clippy -- -D warnings
continue-on-error: true
run: cargo clippy --all-targets -- -D warnings

- name: Check formatting (advisory, non-gating)
- name: Check formatting
if: matrix.os == 'ubuntu-latest'
working-directory: src-tauri
run: cargo fmt --check
continue-on-error: true

type-check:
name: TypeScript Type Check
Expand Down
5 changes: 1 addition & 4 deletions src-tauri/build.rs
Original file line number Diff line number Diff line change
Expand Up @@ -28,10 +28,7 @@ fn main() {
{
let lib_path = toolchain.join("lib/swift/macosx");
if lib_path.exists() {
println!(
"cargo:rustc-link-arg=-Wl,-rpath,{}",
lib_path.display()
);
println!("cargo:rustc-link-arg=-Wl,-rpath,{}", lib_path.display());
}
}
}
Expand Down
32 changes: 21 additions & 11 deletions src-tauri/src/account_export.rs
Original file line number Diff line number Diff line change
Expand Up @@ -118,9 +118,7 @@ pub async fn import_account_export(
}

/// Parse and decrypt, without touching the database.
async fn parse_export(
path: &str,
) -> Result<(Vec<Context>, Vec<StashItem>, usize, usize), String> {
async fn parse_export(path: &str) -> Result<(Vec<Context>, Vec<StashItem>, usize, usize), String> {
let text = tokio::fs::read_to_string(path)
.await
.map_err(|e| format!("Could not read {}: {}", path, e))?;
Expand All @@ -146,9 +144,15 @@ async fn parse_export(
continue;
}
};
let description = open(raw["description"].as_str(), &user_id, "context", &id, "description")
.ok()
.filter(|d| !d.is_empty());
let description = open(
raw["description"].as_str(),
&user_id,
"context",
&id,
"description",
)
.ok()
.filter(|d| !d.is_empty());

contexts.push(Context {
id,
Expand Down Expand Up @@ -229,7 +233,10 @@ fn open(
}

let binding = match (kind, field) {
("stash", "content") => (crate::envelope::Kind::Stash, crate::envelope::Field::Content),
("stash", "content") => (
crate::envelope::Kind::Stash,
crate::envelope::Field::Content,
),
("stash", "enhanced_content") => (
crate::envelope::Kind::Stash,
crate::envelope::Field::EnhancedContent,
Expand Down Expand Up @@ -258,7 +265,7 @@ fn open(
},
)
.map_err(|e| format!("{:?}", e))
.map_err(UiError::from)
.map_err(UiError::from)
}

/// Reduce a context name to something that can be a file name.
Expand Down Expand Up @@ -309,7 +316,10 @@ pub async fn export_whole_account(

let mut by_context: HashMap<String, Vec<String>> = HashMap::new();
for stash in stashes {
by_context.entry(stash.context_id).or_default().push(stash.id);
by_context
.entry(stash.context_id)
.or_default()
.push(stash.id);
}
(contexts, by_context)
};
Expand All @@ -330,8 +340,8 @@ pub async fn export_whole_account(

// One archive per context, named after it. `safe_name` because a context name is
// user-authored and this becomes a path.
let file = std::path::Path::new(&dest_dir)
.join(format!("{}.md", safe_file_name(&context.name)));
let file =
std::path::Path::new(&dest_dir).join(format!("{}.md", safe_file_name(&context.name)));

crate::transfer::export_context_archive(
state.clone(),
Expand Down
24 changes: 16 additions & 8 deletions src-tauri/src/contexts.rs
Original file line number Diff line number Diff line change
Expand Up @@ -11,14 +11,14 @@
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
// See the GNU Affero General Public License for more details.

use std::sync::Arc;
use tauri::State;
use std::time::{SystemTime, UNIX_EPOCH};
use rusqlite::params;
use crate::db::WriteOrigin;
use crate::models::Context;
use crate::state::DbState;
use crate::db::WriteOrigin;
use crate::uierror::UiError;
use rusqlite::params;
use std::sync::Arc;
use std::time::{SystemTime, UNIX_EPOCH};
use tauri::State;

#[tauri::command]
pub async fn get_contexts(state: State<'_, Arc<DbState>>) -> Result<Vec<Context>, UiError> {
Expand All @@ -36,7 +36,10 @@ pub async fn get_contexts(state: State<'_, Arc<DbState>>) -> Result<Vec<Context>
}

#[tauri::command]
pub async fn save_contexts(state: State<'_, Arc<DbState>>, contexts: Vec<Context>) -> Result<(), UiError> {
pub async fn save_contexts(
state: State<'_, Arc<DbState>>,
contexts: Vec<Context>,
) -> Result<(), UiError> {
println!("Saving {} contexts", contexts.len());
let mut db = state.lock_db();
let tx_result = db.conn.transaction().and_then(|tx| {
Expand Down Expand Up @@ -85,7 +88,10 @@ pub async fn save_context(state: State<'_, Arc<DbState>>, context: Context) -> R
/// stamping it with the local clock here would make every pulled record look locally
/// edited and push it straight back on the next sync.
#[tauri::command]
pub async fn import_contexts(state: State<'_, Arc<DbState>>, contexts: Vec<Context>) -> Result<(), UiError> {
pub async fn import_contexts(
state: State<'_, Arc<DbState>>,
contexts: Vec<Context>,
) -> Result<(), UiError> {
let mut db = state.lock_db();
// A context deleted on another device takes its stashes with it here too.
let deleted = db.import_contexts(&contexts).map_err(|e| e.to_string())?;
Expand All @@ -108,7 +114,9 @@ pub async fn delete_context(state: State<'_, Arc<DbState>>, id: String) -> Resul

/// Contexts with local changes the server has not acknowledged yet.
#[tauri::command]
pub async fn claim_pending_contexts(state: State<'_, Arc<DbState>>) -> Result<Vec<Context>, UiError> {
pub async fn claim_pending_contexts(
state: State<'_, Arc<DbState>>,
) -> Result<Vec<Context>, UiError> {
Ok(state.lock_db().claim_pending_contexts().unwrap_or_default())
}

Expand Down
Loading
Loading