Fix second audit findings and restore crash detection dialog
This commit is contained in:
@@ -25,8 +25,7 @@ pub struct BackupPathEntry {
|
||||
}
|
||||
|
||||
fn backups_dir() -> PathBuf {
|
||||
let dir = dirs::data_dir()
|
||||
.unwrap_or_else(|| PathBuf::from("~/.local/share"))
|
||||
let dir = crate::config::data_dir_fallback()
|
||||
.join("driftwood")
|
||||
.join("backups");
|
||||
fs::create_dir_all(&dir).ok();
|
||||
@@ -123,17 +122,17 @@ pub fn create_backup(db: &Database, appimage_id: i64) -> Result<PathBuf, BackupE
|
||||
for entry in &entries {
|
||||
let source = Path::new(&entry.original_path);
|
||||
if source.exists() {
|
||||
// Archive all paths relative to home dir for consistent extract layout.
|
||||
// For non-home paths, archive with full absolute path (leading / stripped by tar).
|
||||
if let Ok(rel) = source.strip_prefix(&home_dir) {
|
||||
tar_args.push("-C".to_string());
|
||||
tar_args.push(home_dir.to_string_lossy().to_string());
|
||||
tar_args.push(rel.to_string_lossy().to_string());
|
||||
} else {
|
||||
tar_args.push("-C".to_string());
|
||||
tar_args.push("/".to_string());
|
||||
tar_args.push(
|
||||
source.parent().unwrap_or(Path::new("/")).to_string_lossy().to_string(),
|
||||
);
|
||||
tar_args.push(
|
||||
source.file_name().unwrap_or_default().to_string_lossy().to_string(),
|
||||
source.strip_prefix("/").unwrap_or(source).to_string_lossy().to_string(),
|
||||
);
|
||||
}
|
||||
}
|
||||
@@ -204,8 +203,9 @@ pub fn restore_backup(archive_path: &Path) -> Result<RestoreResult, BackupError>
|
||||
let extracted = if let Ok(rel) = source.strip_prefix(&home_dir) {
|
||||
temp_dir.path().join(rel)
|
||||
} else {
|
||||
let source_name = source.file_name().unwrap_or_default();
|
||||
temp_dir.path().join(source_name)
|
||||
// Non-home paths are archived with full path (leading / stripped)
|
||||
let abs_rel = source.strip_prefix("/").unwrap_or(source);
|
||||
temp_dir.path().join(abs_rel)
|
||||
};
|
||||
let target = Path::new(&entry.original_path);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user