mirror of
https://gitlab.com/ArkHost/HelixNotes.git
synced 2026-09-19 09:27:29 +02:00
fix: resolve Rust lints
This commit is contained in:
@@ -8,6 +8,7 @@ const ANTHROPIC_API_URL: &str = "https://api.anthropic.com/v1/messages";
|
|||||||
const OPENAI_API_URL: &str = "https://api.openai.com/v1/chat/completions";
|
const OPENAI_API_URL: &str = "https://api.openai.com/v1/chat/completions";
|
||||||
const OLLAMA_DEFAULT_URL: &str = "http://localhost:11434";
|
const OLLAMA_DEFAULT_URL: &str = "http://localhost:11434";
|
||||||
|
|
||||||
|
#[allow(clippy::too_many_arguments)]
|
||||||
pub fn ai_request(
|
pub fn ai_request(
|
||||||
app: AppHandle,
|
app: AppHandle,
|
||||||
provider: String,
|
provider: String,
|
||||||
|
|||||||
@@ -134,7 +134,7 @@ pub fn list_backups(backup_dir: &Path) -> Result<Vec<BackupEntry>, String> {
|
|||||||
let entry = entry.map_err(|e| e.to_string())?;
|
let entry = entry.map_err(|e| e.to_string())?;
|
||||||
let path = entry.path();
|
let path = entry.path();
|
||||||
|
|
||||||
if path.extension().map_or(false, |ext| ext == "zip") {
|
if path.extension().is_some_and(|ext| ext == "zip") {
|
||||||
let filename = path
|
let filename = path
|
||||||
.file_name()
|
.file_name()
|
||||||
.unwrap_or_default()
|
.unwrap_or_default()
|
||||||
|
|||||||
+18
-12
@@ -391,10 +391,12 @@ mod custom_theme_reference_tests {
|
|||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
fn deleting_custom_theme_resets_system_pair_references() {
|
fn deleting_custom_theme_resets_system_pair_references() {
|
||||||
let mut config = AppConfig::default();
|
let mut config = AppConfig {
|
||||||
config.theme = "custom-work".to_string();
|
theme: "custom-work".to_string(),
|
||||||
config.system_light_theme = "custom-work".to_string();
|
system_light_theme: "custom-work".to_string(),
|
||||||
config.system_dark_theme = "custom-work".to_string();
|
system_dark_theme: "custom-work".to_string(),
|
||||||
|
..Default::default()
|
||||||
|
};
|
||||||
|
|
||||||
clear_custom_theme_references(&mut config, "custom-work");
|
clear_custom_theme_references(&mut config, "custom-work");
|
||||||
|
|
||||||
@@ -982,8 +984,8 @@ fn extract_title_fast(raw: &str) -> Option<String> {
|
|||||||
let frontmatter = &after_open[..end];
|
let frontmatter = &after_open[..end];
|
||||||
for line in frontmatter.lines() {
|
for line in frontmatter.lines() {
|
||||||
let line = line.trim();
|
let line = line.trim();
|
||||||
if line.starts_with("title:") {
|
if let Some(title) = line.strip_prefix("title:") {
|
||||||
let val = line[6..].trim();
|
let val = title.trim();
|
||||||
// Strip surrounding quotes
|
// Strip surrounding quotes
|
||||||
if (val.starts_with('"') && val.ends_with('"')) || (val.starts_with('\'') && val.ends_with('\'')) {
|
if (val.starts_with('"') && val.ends_with('"')) || (val.starts_with('\'') && val.ends_with('\'')) {
|
||||||
return Some(val[1..val.len()-1].to_string());
|
return Some(val[1..val.len()-1].to_string());
|
||||||
@@ -1479,6 +1481,7 @@ pub fn set_notebook_icon(
|
|||||||
// ── General Settings ──
|
// ── General Settings ──
|
||||||
|
|
||||||
#[tauri::command]
|
#[tauri::command]
|
||||||
|
#[allow(clippy::too_many_arguments)]
|
||||||
pub fn set_general_settings(
|
pub fn set_general_settings(
|
||||||
state: State<'_, AppState>,
|
state: State<'_, AppState>,
|
||||||
compact_notes: bool,
|
compact_notes: bool,
|
||||||
@@ -2044,6 +2047,7 @@ pub fn get_note_version_content(
|
|||||||
// ── AI ──
|
// ── AI ──
|
||||||
|
|
||||||
#[tauri::command]
|
#[tauri::command]
|
||||||
|
#[allow(clippy::too_many_arguments)]
|
||||||
pub fn set_ai_settings(
|
pub fn set_ai_settings(
|
||||||
state: State<'_, AppState>,
|
state: State<'_, AppState>,
|
||||||
provider: Option<String>,
|
provider: Option<String>,
|
||||||
@@ -2162,9 +2166,9 @@ mod vault_identity_tests {
|
|||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
fn bookmark_identity_disambiguates_vaults_with_the_same_path() {
|
fn bookmark_identity_disambiguates_vaults_with_the_same_path() {
|
||||||
let mut config = AppConfig::default();
|
let mut config = AppConfig {
|
||||||
config.active_vault = Some("/same/path".to_string());
|
active_vault: Some("/same/path".to_string()),
|
||||||
config.vaults = vec![
|
vaults: vec![
|
||||||
VaultConfig {
|
VaultConfig {
|
||||||
path: "/same/path".to_string(),
|
path: "/same/path".to_string(),
|
||||||
name: "Local".to_string(),
|
name: "Local".to_string(),
|
||||||
@@ -2176,9 +2180,10 @@ mod vault_identity_tests {
|
|||||||
bookmark_id: Some("bookmark".to_string()),
|
bookmark_id: Some("bookmark".to_string()),
|
||||||
..Default::default()
|
..Default::default()
|
||||||
},
|
},
|
||||||
];
|
],
|
||||||
|
active_bookmark_id: Some("bookmark".to_string()),
|
||||||
config.active_bookmark_id = Some("bookmark".to_string());
|
..Default::default()
|
||||||
|
};
|
||||||
assert_eq!(active_vault_config(&config).unwrap().name, "Files");
|
assert_eq!(active_vault_config(&config).unwrap().name, "Files");
|
||||||
|
|
||||||
config.active_bookmark_id = None;
|
config.active_bookmark_id = None;
|
||||||
@@ -2204,6 +2209,7 @@ fn sync_config_from(config: &AppConfig) -> Result<crate::sync::WebdavConfig, Str
|
|||||||
}
|
}
|
||||||
|
|
||||||
#[tauri::command]
|
#[tauri::command]
|
||||||
|
#[allow(clippy::too_many_arguments)]
|
||||||
pub fn set_sync_settings(
|
pub fn set_sync_settings(
|
||||||
state: State<'_, AppState>,
|
state: State<'_, AppState>,
|
||||||
provider: Option<String>,
|
provider: Option<String>,
|
||||||
|
|||||||
@@ -115,7 +115,7 @@ pub fn list_versions(vault_path: &str, note_id: &str) -> Result<Vec<VersionEntry
|
|||||||
for entry in fs::read_dir(&dir).map_err(|e| e.to_string())? {
|
for entry in fs::read_dir(&dir).map_err(|e| e.to_string())? {
|
||||||
let entry = entry.map_err(|e| e.to_string())?;
|
let entry = entry.map_err(|e| e.to_string())?;
|
||||||
let path = entry.path();
|
let path = entry.path();
|
||||||
if path.extension().map_or(false, |ext| ext == "md") {
|
if path.extension().is_some_and(|ext| ext == "md") {
|
||||||
let filename = path
|
let filename = path
|
||||||
.file_stem()
|
.file_stem()
|
||||||
.unwrap_or_default()
|
.unwrap_or_default()
|
||||||
@@ -153,7 +153,7 @@ pub fn get_version(vault_path: &str, note_id: &str, timestamp: &str) -> Result<S
|
|||||||
let date_part = ×tamp[..t_pos];
|
let date_part = ×tamp[..t_pos];
|
||||||
let time_part = timestamp[t_pos + 1..].trim_end_matches('Z');
|
let time_part = timestamp[t_pos + 1..].trim_end_matches('Z');
|
||||||
let time_dashes = time_part.replace(':', "-");
|
let time_dashes = time_part.replace(':', "-");
|
||||||
format!("{}.md", format!("{}T{}", date_part, time_dashes))
|
format!("{date_part}T{time_dashes}.md")
|
||||||
} else {
|
} else {
|
||||||
format!("{}.md", timestamp)
|
format!("{}.md", timestamp)
|
||||||
};
|
};
|
||||||
@@ -168,7 +168,7 @@ fn prune_versions(dir: &Path, max: u32) -> Result<(), String> {
|
|||||||
.map_err(|e| e.to_string())?
|
.map_err(|e| e.to_string())?
|
||||||
.filter_map(|e| e.ok())
|
.filter_map(|e| e.ok())
|
||||||
.map(|e| e.path())
|
.map(|e| e.path())
|
||||||
.filter(|p| p.extension().map_or(false, |ext| ext == "md"))
|
.filter(|p| p.extension().is_some_and(|ext| ext == "md"))
|
||||||
.collect();
|
.collect();
|
||||||
|
|
||||||
// Sort by name (timestamps sort lexicographically) - newest last
|
// Sort by name (timestamps sort lexicographically) - newest last
|
||||||
|
|||||||
@@ -219,7 +219,7 @@ pub fn run() {
|
|||||||
let external_url = percent_decode(encoded);
|
let external_url = percent_decode(encoded);
|
||||||
|
|
||||||
if !external_url.starts_with("http://") && !external_url.starts_with("https://") {
|
if !external_url.starts_with("http://") && !external_url.starts_with("https://") {
|
||||||
let _ = responder.respond(
|
responder.respond(
|
||||||
tauri::http::Response::builder()
|
tauri::http::Response::builder()
|
||||||
.status(400)
|
.status(400)
|
||||||
.body(Vec::new())
|
.body(Vec::new())
|
||||||
@@ -234,7 +234,7 @@ pub fn run() {
|
|||||||
{
|
{
|
||||||
Ok(c) => c,
|
Ok(c) => c,
|
||||||
Err(_) => {
|
Err(_) => {
|
||||||
let _ = responder.respond(
|
responder.respond(
|
||||||
tauri::http::Response::builder()
|
tauri::http::Response::builder()
|
||||||
.status(502)
|
.status(502)
|
||||||
.body(Vec::new())
|
.body(Vec::new())
|
||||||
@@ -255,7 +255,7 @@ pub fn run() {
|
|||||||
let status = resp.status().as_u16();
|
let status = resp.status().as_u16();
|
||||||
match resp.bytes() {
|
match resp.bytes() {
|
||||||
Ok(bytes) => {
|
Ok(bytes) => {
|
||||||
let _ = responder.respond(
|
responder.respond(
|
||||||
tauri::http::Response::builder()
|
tauri::http::Response::builder()
|
||||||
.status(status)
|
.status(status)
|
||||||
.header("Content-Type", &content_type)
|
.header("Content-Type", &content_type)
|
||||||
@@ -265,7 +265,7 @@ pub fn run() {
|
|||||||
);
|
);
|
||||||
}
|
}
|
||||||
Err(_) => {
|
Err(_) => {
|
||||||
let _ = responder.respond(
|
responder.respond(
|
||||||
tauri::http::Response::builder()
|
tauri::http::Response::builder()
|
||||||
.status(502)
|
.status(502)
|
||||||
.body(Vec::new())
|
.body(Vec::new())
|
||||||
@@ -275,7 +275,7 @@ pub fn run() {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
Err(_) => {
|
Err(_) => {
|
||||||
let _ = responder.respond(
|
responder.respond(
|
||||||
tauri::http::Response::builder()
|
tauri::http::Response::builder()
|
||||||
.status(502)
|
.status(502)
|
||||||
.body(Vec::new())
|
.body(Vec::new())
|
||||||
@@ -350,9 +350,9 @@ pub fn run() {
|
|||||||
let _ = window.hide();
|
let _ = window.hide();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
tauri::WindowEvent::Destroyed => {
|
tauri::WindowEvent::Destroyed
|
||||||
// When main window is destroyed, close all note windows
|
// When main window is destroyed, close all note windows
|
||||||
if window.label() == "main" {
|
if window.label() == "main" => {
|
||||||
let app = window.app_handle();
|
let app = window.app_handle();
|
||||||
for (label, win) in app.webview_windows() {
|
for (label, win) in app.webview_windows() {
|
||||||
if label.starts_with("note-") {
|
if label.starts_with("note-") {
|
||||||
@@ -360,7 +360,6 @@ pub fn run() {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
_ => {}
|
_ => {}
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|||||||
@@ -290,7 +290,7 @@ impl SearchIndex {
|
|||||||
doc.add_text(self.path_field, &path_str);
|
doc.add_text(self.path_field, &path_str);
|
||||||
doc.add_text(self.title_field, &meta.title);
|
doc.add_text(self.title_field, &meta.title);
|
||||||
doc.add_text(self.body_field, &content);
|
doc.add_text(self.body_field, &content);
|
||||||
doc.add_text(self.tags_field, &meta.tags.join(" "));
|
doc.add_text(self.tags_field, meta.tags.join(" "));
|
||||||
let _ = writer.add_document(doc);
|
let _ = writer.add_document(doc);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -321,7 +321,7 @@ impl SearchIndex {
|
|||||||
doc.add_text(self.path_field, path);
|
doc.add_text(self.path_field, path);
|
||||||
doc.add_text(self.title_field, &meta.title);
|
doc.add_text(self.title_field, &meta.title);
|
||||||
doc.add_text(self.body_field, &content);
|
doc.add_text(self.body_field, &content);
|
||||||
doc.add_text(self.tags_field, &meta.tags.join(" "));
|
doc.add_text(self.tags_field, meta.tags.join(" "));
|
||||||
let _ = writer.add_document(doc);
|
let _ = writer.add_document(doc);
|
||||||
|
|
||||||
writer.commit().map_err(|e| e.to_string())?;
|
writer.commit().map_err(|e| e.to_string())?;
|
||||||
@@ -341,7 +341,7 @@ impl SearchIndex {
|
|||||||
let reader = self.index.reader().map_err(|e| e.to_string())?;
|
let reader = self.index.reader().map_err(|e| e.to_string())?;
|
||||||
let searcher = reader.searcher();
|
let searcher = reader.searcher();
|
||||||
|
|
||||||
let fields = vec![self.title_field, self.body_field, self.tags_field];
|
let fields = [self.title_field, self.body_field, self.tags_field];
|
||||||
// Tokenize the query with the SAME CJK-aware analyzer used for indexing, so a
|
// Tokenize the query with the SAME CJK-aware analyzer used for indexing, so a
|
||||||
// Chinese/Japanese/Korean query becomes the same uni/bigram tokens as the docs.
|
// Chinese/Japanese/Korean query becomes the same uni/bigram tokens as the docs.
|
||||||
// (For pure-ASCII queries this yields the same lowercased word tokens as before.)
|
// (For pure-ASCII queries this yields the same lowercased word tokens as before.)
|
||||||
|
|||||||
@@ -108,7 +108,7 @@ pub fn serialize_frontmatter(meta: &NoteMeta) -> String {
|
|||||||
"[{}]",
|
"[{}]",
|
||||||
meta.tags
|
meta.tags
|
||||||
.iter()
|
.iter()
|
||||||
.map(|t| format!("{}", t))
|
.map(|t| t.to_string())
|
||||||
.collect::<Vec<_>>()
|
.collect::<Vec<_>>()
|
||||||
.join(", ")
|
.join(", ")
|
||||||
)
|
)
|
||||||
@@ -279,7 +279,7 @@ fn strip_html_and_markdown(input: &str) -> String {
|
|||||||
chars.next(); // skip '['
|
chars.next(); // skip '['
|
||||||
let mut depth = 1;
|
let mut depth = 1;
|
||||||
// Skip alt text
|
// Skip alt text
|
||||||
while let Some(c) = chars.next() {
|
for c in chars.by_ref() {
|
||||||
if c == '[' {
|
if c == '[' {
|
||||||
depth += 1;
|
depth += 1;
|
||||||
}
|
}
|
||||||
@@ -294,7 +294,7 @@ fn strip_html_and_markdown(input: &str) -> String {
|
|||||||
if chars.peek() == Some(&'(') {
|
if chars.peek() == Some(&'(') {
|
||||||
chars.next();
|
chars.next();
|
||||||
let mut depth = 1;
|
let mut depth = 1;
|
||||||
while let Some(c) = chars.next() {
|
for c in chars.by_ref() {
|
||||||
if c == '(' {
|
if c == '(' {
|
||||||
depth += 1;
|
depth += 1;
|
||||||
}
|
}
|
||||||
@@ -313,7 +313,7 @@ fn strip_html_and_markdown(input: &str) -> String {
|
|||||||
if ch == '[' {
|
if ch == '[' {
|
||||||
let mut link_text = String::new();
|
let mut link_text = String::new();
|
||||||
let mut depth = 1;
|
let mut depth = 1;
|
||||||
while let Some(c) = chars.next() {
|
for c in chars.by_ref() {
|
||||||
if c == '[' {
|
if c == '[' {
|
||||||
depth += 1;
|
depth += 1;
|
||||||
}
|
}
|
||||||
@@ -329,7 +329,7 @@ fn strip_html_and_markdown(input: &str) -> String {
|
|||||||
if chars.peek() == Some(&'(') {
|
if chars.peek() == Some(&'(') {
|
||||||
chars.next();
|
chars.next();
|
||||||
let mut depth = 1;
|
let mut depth = 1;
|
||||||
while let Some(c) = chars.next() {
|
for c in chars.by_ref() {
|
||||||
if c == '(' {
|
if c == '(' {
|
||||||
depth += 1;
|
depth += 1;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -116,9 +116,7 @@ pub fn import(vault_path: &str) -> Result<ImportResult, String> {
|
|||||||
result.links_converted += 1;
|
result.links_converted += 1;
|
||||||
format!("", alt, link_target)
|
format!("", alt, link_target)
|
||||||
} else {
|
} else {
|
||||||
let display = if alt_param.is_empty() {
|
let display = if alt_param.is_empty() || is_dimension_spec(alt_param) {
|
||||||
file_part.rsplit('/').next().unwrap_or(file_part)
|
|
||||||
} else if is_dimension_spec(alt_param) {
|
|
||||||
file_part.rsplit('/').next().unwrap_or(file_part)
|
file_part.rsplit('/').next().unwrap_or(file_part)
|
||||||
} else {
|
} else {
|
||||||
alt_param
|
alt_param
|
||||||
@@ -267,7 +265,7 @@ fn normalize_frontmatter(raw: &str, path: &Path) -> (NoteMeta, String) {
|
|||||||
let tags = normalize_tags(&mapping);
|
let tags = normalize_tags(&mapping);
|
||||||
|
|
||||||
let title = mapping
|
let title = mapping
|
||||||
.get(&serde_yaml::Value::String("title".into()))
|
.get(serde_yaml::Value::String("title".into()))
|
||||||
.and_then(|v| v.as_str())
|
.and_then(|v| v.as_str())
|
||||||
.map(|s| s.to_string())
|
.map(|s| s.to_string())
|
||||||
.unwrap_or_else(|| {
|
.unwrap_or_else(|| {
|
||||||
@@ -283,7 +281,7 @@ fn normalize_frontmatter(raw: &str, path: &Path) -> (NoteMeta, String) {
|
|||||||
});
|
});
|
||||||
|
|
||||||
let id = mapping
|
let id = mapping
|
||||||
.get(&serde_yaml::Value::String("id".into()))
|
.get(serde_yaml::Value::String("id".into()))
|
||||||
.and_then(|v| v.as_str())
|
.and_then(|v| v.as_str())
|
||||||
.map(|s| s.to_string())
|
.map(|s| s.to_string())
|
||||||
.filter(|s| !s.is_empty())
|
.filter(|s| !s.is_empty())
|
||||||
@@ -293,9 +291,9 @@ fn normalize_frontmatter(raw: &str, path: &Path) -> (NoteMeta, String) {
|
|||||||
.iter()
|
.iter()
|
||||||
.find_map(|key| {
|
.find_map(|key| {
|
||||||
mapping
|
mapping
|
||||||
.get(&serde_yaml::Value::String((*key).into()))
|
.get(serde_yaml::Value::String((*key).into()))
|
||||||
.and_then(|v| v.as_str())
|
.and_then(|v| v.as_str())
|
||||||
.and_then(|s| frontmatter::parse_date_flexible(s))
|
.and_then(frontmatter::parse_date_flexible)
|
||||||
})
|
})
|
||||||
.or_else(|| file_created(path))
|
.or_else(|| file_created(path))
|
||||||
.unwrap_or_else(Utc::now);
|
.unwrap_or_else(Utc::now);
|
||||||
@@ -304,15 +302,15 @@ fn normalize_frontmatter(raw: &str, path: &Path) -> (NoteMeta, String) {
|
|||||||
.iter()
|
.iter()
|
||||||
.find_map(|key| {
|
.find_map(|key| {
|
||||||
mapping
|
mapping
|
||||||
.get(&serde_yaml::Value::String((*key).into()))
|
.get(serde_yaml::Value::String((*key).into()))
|
||||||
.and_then(|v| v.as_str())
|
.and_then(|v| v.as_str())
|
||||||
.and_then(|s| frontmatter::parse_date_flexible(s))
|
.and_then(frontmatter::parse_date_flexible)
|
||||||
})
|
})
|
||||||
.or_else(|| file_modified(path))
|
.or_else(|| file_modified(path))
|
||||||
.unwrap_or_else(Utc::now);
|
.unwrap_or_else(Utc::now);
|
||||||
|
|
||||||
let pinned = mapping
|
let pinned = mapping
|
||||||
.get(&serde_yaml::Value::String("pinned".into()))
|
.get(serde_yaml::Value::String("pinned".into()))
|
||||||
.and_then(|v| v.as_bool())
|
.and_then(|v| v.as_bool())
|
||||||
.unwrap_or(false);
|
.unwrap_or(false);
|
||||||
|
|
||||||
@@ -332,7 +330,7 @@ fn normalize_tags(mapping: &serde_yaml::Mapping) -> Vec<String> {
|
|||||||
let mut seen = HashSet::new();
|
let mut seen = HashSet::new();
|
||||||
|
|
||||||
for key in &["tags", "tag"] {
|
for key in &["tags", "tag"] {
|
||||||
if let Some(val) = mapping.get(&serde_yaml::Value::String((*key).into())) {
|
if let Some(val) = mapping.get(serde_yaml::Value::String((*key).into())) {
|
||||||
for raw in yaml_value_to_strings(val) {
|
for raw in yaml_value_to_strings(val) {
|
||||||
let cleaned = raw.trim().trim_start_matches('#').trim().to_string();
|
let cleaned = raw.trim().trim_start_matches('#').trim().to_string();
|
||||||
if !cleaned.is_empty() && seen.insert(cleaned.to_lowercase()) {
|
if !cleaned.is_empty() && seen.insert(cleaned.to_lowercase()) {
|
||||||
@@ -686,7 +684,7 @@ fn cleanup_empty_dirs(root: &Path) {
|
|||||||
.map(|e| e.path().to_path_buf())
|
.map(|e| e.path().to_path_buf())
|
||||||
.collect();
|
.collect();
|
||||||
|
|
||||||
dirs.sort_by(|a, b| b.components().count().cmp(&a.components().count()));
|
dirs.sort_by_key(|path| std::cmp::Reverse(path.components().count()));
|
||||||
|
|
||||||
for dir in dirs {
|
for dir in dirs {
|
||||||
let dir_str = dir.to_string_lossy();
|
let dir_str = dir.to_string_lossy();
|
||||||
|
|||||||
@@ -381,7 +381,7 @@ pub fn scan_notes(vault_path: &str, notebook_path: Option<&str>) -> Result<Vec<N
|
|||||||
.collect();
|
.collect();
|
||||||
|
|
||||||
log::info!("scan_notes: mobile scan found {} notes", notes.len());
|
log::info!("scan_notes: mobile scan found {} notes", notes.len());
|
||||||
notes.sort_by(|a, b| b.meta.modified.cmp(&a.meta.modified));
|
notes.sort_by_key(|note| std::cmp::Reverse(note.meta.modified));
|
||||||
return Ok(notes);
|
return Ok(notes);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -397,7 +397,7 @@ pub fn scan_notes(vault_path: &str, notebook_path: Option<&str>) -> Result<Vec<N
|
|||||||
} else {
|
} else {
|
||||||
WalkDir::new(root)
|
WalkDir::new(root)
|
||||||
.into_iter()
|
.into_iter()
|
||||||
.filter_entry(|e| !is_hidden(e.path()) && !e.path().starts_with(&helixnotes_dir(vault_path)))
|
.filter_entry(|e| !is_hidden(e.path()) && !e.path().starts_with(helixnotes_dir(vault_path)))
|
||||||
.filter_map(|e| e.ok())
|
.filter_map(|e| e.ok())
|
||||||
.map(|e| e.path().to_path_buf())
|
.map(|e| e.path().to_path_buf())
|
||||||
.filter(|p| p.is_file() && p.extension().and_then(|x| x.to_str()) == Some("md"))
|
.filter(|p| p.is_file() && p.extension().and_then(|x| x.to_str()) == Some("md"))
|
||||||
@@ -409,7 +409,7 @@ pub fn scan_notes(vault_path: &str, notebook_path: Option<&str>) -> Result<Vec<N
|
|||||||
.filter_map(|path| read_note_entry_fast(path, vault_root).ok())
|
.filter_map(|path| read_note_entry_fast(path, vault_root).ok())
|
||||||
.collect();
|
.collect();
|
||||||
|
|
||||||
notes.sort_by(|a, b| b.meta.modified.cmp(&a.meta.modified));
|
notes.sort_by_key(|note| std::cmp::Reverse(note.meta.modified));
|
||||||
Ok(notes)
|
Ok(notes)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -1176,7 +1176,7 @@ pub fn get_trash_contents(vault_path: &str) -> Result<TrashContents, String> {
|
|||||||
};
|
};
|
||||||
let modified = fs::metadata(&path)
|
let modified = fs::metadata(&path)
|
||||||
.and_then(|m| m.modified())
|
.and_then(|m| m.modified())
|
||||||
.map(|t| DateTime::<Utc>::from(t))
|
.map(DateTime::<Utc>::from)
|
||||||
.unwrap_or_else(|_| Utc::now());
|
.unwrap_or_else(|_| Utc::now());
|
||||||
notebooks.push(TrashNotebookEntry {
|
notebooks.push(TrashNotebookEntry {
|
||||||
name,
|
name,
|
||||||
@@ -1187,8 +1187,8 @@ pub fn get_trash_contents(vault_path: &str) -> Result<TrashContents, String> {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
notes.sort_by(|a, b| b.meta.modified.cmp(&a.meta.modified));
|
notes.sort_by_key(|note| std::cmp::Reverse(note.meta.modified));
|
||||||
notebooks.sort_by(|a, b| b.modified.cmp(&a.modified));
|
notebooks.sort_by_key(|notebook| std::cmp::Reverse(notebook.modified));
|
||||||
Ok(TrashContents { notes, notebooks })
|
Ok(TrashContents { notes, notebooks })
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user