Skip to content

Commit b3fa2bc

Browse files
authored
Merge pull request #199 from prefrontalsys/fix/backup-extension-handling
Fix: append .bak extension instead of replacing file extension
2 parents 15db3ff + f74448e commit b3fa2bc

2 files changed

Lines changed: 10 additions & 4 deletions

File tree

src-tauri/src/commands/cloud_sync.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,8 +16,8 @@ use tauri::State;
1616
fn find_gh() -> std::path::PathBuf {
1717
for candidate in &[
1818
"/opt/homebrew/bin/gh", // Homebrew on Apple Silicon
19-
"/usr/local/bin/gh", // Homebrew on Intel / manual install
20-
"/usr/bin/gh", // System install
19+
"/usr/local/bin/gh", // Homebrew on Intel / manual install
20+
"/usr/bin/gh", // System install
2121
] {
2222
if std::path::Path::new(candidate).exists() {
2323
return candidate.into();

src-tauri/src/services/gist_sync.rs

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -558,7 +558,8 @@ pub fn apply_pulled_payload(
558558
}
559559
// Back up existing file before overwriting
560560
if path.exists() {
561-
let backup = path.with_extension("md.bak");
561+
let file_name = path.file_name().unwrap_or_default().to_string_lossy();
562+
let backup = path.with_file_name(format!("{}.bak", file_name));
562563
let _ = std::fs::copy(&path, &backup);
563564
}
564565
std::fs::write(&path, content)?;
@@ -681,7 +682,12 @@ pub fn apply_pulled_payload(
681682
}
682683
// Back up existing file before overwriting
683684
if claude_md_path.exists() {
684-
let backup = claude_md_path.with_extension("md.bak");
685+
let file_name = claude_md_path
686+
.file_name()
687+
.unwrap_or_default()
688+
.to_string_lossy();
689+
let backup =
690+
claude_md_path.with_file_name(format!("{}.bak", file_name));
685691
let _ = std::fs::copy(&claude_md_path, &backup);
686692
}
687693
if let Err(e) = std::fs::write(&claude_md_path, content) {

0 commit comments

Comments
 (0)