Skip to content

Commit ce5fcd9

Browse files
chore: rustfmt + bump version to 0.1.5
1 parent 902df7a commit ce5fcd9

File tree

7 files changed

+54
-29
lines changed

7 files changed

+54
-29
lines changed

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
{
22
"name": "codexrelay",
33
"private": true,
4-
"version": "0.1.4",
4+
"version": "0.1.5",
55
"type": "module",
66
"scripts": {
77
"dev": "vite",

src-tauri/Cargo.lock

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

src-tauri/Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
[package]
22
name = "codexrelay"
3-
version = "0.1.4"
3+
version = "0.1.5"
44
description = "Cross-device Codex CLI session transfer manager"
55
authors = ["you"]
66
edition = "2021"

src-tauri/src/lib.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,8 +9,8 @@ mod id_extract;
99
mod ops;
1010
mod preview;
1111
mod settings;
12-
mod update;
1312
mod transfers;
13+
mod update;
1414
mod vault;
1515
mod vault_usage;
1616

src-tauri/src/ops.rs

Lines changed: 40 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -341,13 +341,13 @@ pub fn export_sessions<R: tauri::Runtime>(
341341
}
342342
}
343343
if ids.is_empty() {
344-
return Err(AppError::validation("会话ID为空")
345-
.with_hint("请粘贴或输入至少一个 UUID 会话ID。"));
344+
return Err(
345+
AppError::validation("会话ID为空").with_hint("请粘贴或输入至少一个 UUID 会话ID。")
346+
);
346347
}
347348

348349
let export_dir = app_paths::download_dir().map_err(AppError::from)?;
349-
fs::create_dir_all(&export_dir)
350-
.map_err(|e| AppError::io(format!("create export dir: {e}")))?;
350+
fs::create_dir_all(&export_dir).map_err(|e| AppError::io(format!("create export dir: {e}")))?;
351351

352352
let mut items: Vec<ExportSessionItem> = Vec::new();
353353
let mut errors: Vec<ExportSessionError> = Vec::new();
@@ -356,7 +356,11 @@ pub fn export_sessions<R: tauri::Runtime>(
356356
let name = if ids.len() == 1 {
357357
params.name.clone()
358358
} else {
359-
format!("{} [{}]", params.name, &sid.chars().take(8).collect::<String>())
359+
format!(
360+
"{} [{}]",
361+
params.name,
362+
&sid.chars().take(8).collect::<String>()
363+
)
360364
};
361365
match export_session(
362366
app,
@@ -378,7 +382,11 @@ pub fn export_sessions<R: tauri::Runtime>(
378382
}),
379383
Err(e) => errors.push(ExportSessionError {
380384
session_id: sid.clone(),
381-
message: format!("{}{}", e.message, e.hint.map(|h| format!("({})", h)).unwrap_or_default()),
385+
message: format!(
386+
"{}{}",
387+
e.message,
388+
e.hint.map(|h| format!("({})", h)).unwrap_or_default()
389+
),
382390
}),
383391
}
384392
}
@@ -876,7 +884,11 @@ pub fn import_bundles<R: tauri::Runtime>(
876884
// Best-effort: include short id in name when importing multiple sessions.
877885
let sid = read_manifest_session_id(&src).unwrap_or_else(|_| "".to_string());
878886
let derived_name = if paths.len() > 1 && !sid.is_empty() {
879-
format!("{} [{}]", params.name, &sid.chars().take(8).collect::<String>())
887+
format!(
888+
"{} [{}]",
889+
params.name,
890+
&sid.chars().take(8).collect::<String>()
891+
)
880892
} else {
881893
params.name.clone()
882894
};
@@ -916,9 +928,8 @@ pub fn import_bundles<R: tauri::Runtime>(
916928
.map_err(AppError::from)?
917929
.join("tmp_batch_import")
918930
.join(uuid::Uuid::now_v7().to_string());
919-
fs::create_dir_all(&tmp_root).map_err(|e| {
920-
AppError::io(format!("create tmp_batch_import dir: {e}"))
921-
})?;
931+
fs::create_dir_all(&tmp_root)
932+
.map_err(|e| AppError::io(format!("create tmp_batch_import dir: {e}")))?;
922933

923934
for (idx, entry_name) in entries.iter().enumerate() {
924935
let tmp_zip = tmp_root.join(format!("inner-{idx}.zip"));
@@ -932,7 +943,11 @@ pub fn import_bundles<R: tauri::Runtime>(
932943

933944
let sid = read_manifest_session_id(&tmp_zip).unwrap_or_else(|_| "".to_string());
934945
let derived_name = if !sid.is_empty() {
935-
format!("{} [{}]", params.name, &sid.chars().take(8).collect::<String>())
946+
format!(
947+
"{} [{}]",
948+
params.name,
949+
&sid.chars().take(8).collect::<String>()
950+
)
936951
} else {
937952
params.name.clone()
938953
};
@@ -1450,7 +1465,10 @@ fn build_batch_bundle_filename(op: &str, name: &str) -> String {
14501465
if file.chars().count() > MAX_CHARS {
14511466
let extra = file.chars().count().saturating_sub(MAX_CHARS);
14521467
let target_len = safe_name.chars().count().saturating_sub(extra + 3);
1453-
let safe_name = safe_name.chars().take(target_len.max(8)).collect::<String>();
1468+
let safe_name = safe_name
1469+
.chars()
1470+
.take(target_len.max(8))
1471+
.collect::<String>();
14541472
file = format!("CodexRelay-{op}-batch-{ts}-{safe_name}.zip");
14551473
}
14561474
file
@@ -1524,10 +1542,8 @@ enum ZipBundleKind {
15241542
}
15251543

15261544
fn classify_zip_bundle(zip_path: &Path) -> AppResult<ZipBundleKind> {
1527-
let f =
1528-
fs::File::open(zip_path).map_err(|e| AppError::io(format!("open zip: {e}")))?;
1529-
let mut z =
1530-
zip::ZipArchive::new(f).map_err(|e| AppError::io(format!("read zip: {e}")))?;
1545+
let f = fs::File::open(zip_path).map_err(|e| AppError::io(format!("open zip: {e}")))?;
1546+
let mut z = zip::ZipArchive::new(f).map_err(|e| AppError::io(format!("read zip: {e}")))?;
15311547

15321548
let has_manifest = z.by_name("manifest.json").is_ok();
15331549
let has_rollout = z.by_name("rollout.jsonl").is_ok();
@@ -1567,7 +1583,11 @@ fn classify_zip_bundle(zip_path: &Path) -> AppResult<ZipBundleKind> {
15671583
Ok(ZipBundleKind::Unknown)
15681584
}
15691585

1570-
fn extract_zip_entry_to_file(zip_path: &Path, entry_name: &str, out_path: &Path) -> Result<(), String> {
1586+
fn extract_zip_entry_to_file(
1587+
zip_path: &Path,
1588+
entry_name: &str,
1589+
out_path: &Path,
1590+
) -> Result<(), String> {
15711591
const MAX_BYTES: u64 = 4 * 1024 * 1024 * 1024; // 4 GiB
15721592
let f = fs::File::open(zip_path).map_err(|e| format!("open zip: {e}"))?;
15731593
let mut z = zip::ZipArchive::new(f).map_err(|e| format!("read zip: {e}"))?;
@@ -1588,7 +1608,9 @@ fn extract_zip_entry_to_file(zip_path: &Path, entry_name: &str, out_path: &Path)
15881608
let mut buf = [0u8; 1024 * 64];
15891609
let mut total: u64 = 0;
15901610
loop {
1591-
let n = entry.read(&mut buf).map_err(|e| format!("read entry: {e}"))?;
1611+
let n = entry
1612+
.read(&mut buf)
1613+
.map_err(|e| format!("read entry: {e}"))?;
15921614
if n == 0 {
15931615
break;
15941616
}

src-tauri/src/update.rs

Lines changed: 9 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -41,11 +41,13 @@ pub fn check_update(current_version: &str) -> AppResult<UpdateCheckResult> {
4141
let body = resp
4242
.into_string()
4343
.map_err(|e| AppError::io(format!("读取更新信息失败:{e}")))?;
44-
let rel: GitHubLatestRelease =
45-
serde_json::from_str(&body).map_err(|e| AppError::internal(format!("parse release: {e}")))?;
44+
let rel: GitHubLatestRelease = serde_json::from_str(&body)
45+
.map_err(|e| AppError::internal(format!("parse release: {e}")))?;
4646

4747
if rel.draft {
48-
return Err(AppError::internal("GitHub latest release 是 draft(不应发生)"));
48+
return Err(AppError::internal(
49+
"GitHub latest release 是 draft(不应发生)",
50+
));
4951
}
5052
if rel.prerelease {
5153
// `latest` normally excludes prerelease; keep guardrail anyway.
@@ -55,8 +57,10 @@ pub fn check_update(current_version: &str) -> AppResult<UpdateCheckResult> {
5557
}
5658

5759
let latest_version = rel.tag_name.trim_start_matches('v').to_string();
58-
let has_update = match (parse_simple_semver(&latest_version), parse_simple_semver(current_version))
59-
{
60+
let has_update = match (
61+
parse_simple_semver(&latest_version),
62+
parse_simple_semver(current_version),
63+
) {
6064
(Some(latest), Some(current)) => latest > current,
6165
_ => latest_version != current_version,
6266
};
@@ -78,4 +82,3 @@ fn parse_simple_semver(v: &str) -> Option<(u64, u64, u64)> {
7882
let c = it.next()?.parse().ok()?;
7983
Some((a, b, c))
8084
}
81-

src-tauri/tauri.conf.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
{
22
"$schema": "https://schema.tauri.app/config/2",
33
"productName": "CodexRelay",
4-
"version": "0.1.4",
4+
"version": "0.1.5",
55
"identifier": "com.codexrelay.desktop",
66
"build": {
77
"beforeDevCommand": "pnpm dev:tauri",

0 commit comments

Comments
 (0)