fix: broken edit.rs
This commit is contained in:
+14
-7
@@ -10,7 +10,7 @@ use std::io::Write;
|
|||||||
use std::path::PathBuf;
|
use std::path::PathBuf;
|
||||||
use std::{fs::File, fs::read_dir, io::Read, process::Command};
|
use std::{fs::File, fs::read_dir, io::Read, process::Command};
|
||||||
|
|
||||||
pub fn edit(file_path: Vec<PathBuf>, extra_files: [String; 9]) -> std::io::Result<()> {
|
pub fn edit(file_path: Vec<PathBuf>, extra_files: &[String]) -> std::io::Result<()> {
|
||||||
let tmp_file_path = PathBuf::from("/tmp/keks-sort-metadata");
|
let tmp_file_path = PathBuf::from("/tmp/keks-sort-metadata");
|
||||||
let mut tmp_file = File::create(&tmp_file_path)?;
|
let mut tmp_file = File::create(&tmp_file_path)?;
|
||||||
let editor = var("EDITOR").unwrap();
|
let editor = var("EDITOR").unwrap();
|
||||||
@@ -34,15 +34,22 @@ pub fn edit(file_path: Vec<PathBuf>, extra_files: [String; 9]) -> std::io::Resul
|
|||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
let tag = crate::get_metadata(&path);
|
let tag = match crate::get_metadata(&path) {
|
||||||
|
Ok(tag) => tag,
|
||||||
|
Err(err) => {
|
||||||
|
eprintln!("Failed to get metadata for {:?}: {}", path, err);
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
};
|
||||||
files.push(FileMetadata { path, tag });
|
files.push(FileMetadata { path, tag });
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
let tag = &crate::get_metadata(file);
|
if let Ok(tag) = crate::get_metadata(file) {
|
||||||
files.push(FileMetadata {
|
files.push(FileMetadata {
|
||||||
path: file.to_path_buf(),
|
path: file.to_path_buf(),
|
||||||
tag: tag.clone(),
|
tag: tag.clone(),
|
||||||
});
|
});
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user