complete local markdown resource lifecycle contract
This commit is contained in:
@@ -212,26 +212,29 @@ fn spawn_local_folder_watcher(
|
||||
&root_uri_for_task,
|
||||
&relative_path,
|
||||
);
|
||||
if !is_markdown_path(&path) {
|
||||
continue;
|
||||
}
|
||||
|
||||
// 外部文件变更→更新 BufferStore
|
||||
let document_id =
|
||||
format!("local-md:{}", encode_local_id_segment(&relative_path));
|
||||
if let Ok(ws_id) =
|
||||
local_workspace_id_from_root_uri(&root_uri_for_task)
|
||||
{
|
||||
let ws_path =
|
||||
crate::document_buffer_store::build_local_folder_workspace_path(
|
||||
&ws_id,
|
||||
&root_uri_for_task,
|
||||
&relative_path,
|
||||
&document_id,
|
||||
let document_id = if is_markdown_path(&path) {
|
||||
let document_id =
|
||||
format!("local-md:{}", encode_local_id_segment(&relative_path));
|
||||
// 外部 Markdown 变更→更新 BufferStore
|
||||
if let Ok(ws_id) =
|
||||
local_workspace_id_from_root_uri(&root_uri_for_task)
|
||||
{
|
||||
let ws_path =
|
||||
crate::document_buffer_store::build_local_folder_workspace_path(
|
||||
&ws_id,
|
||||
&root_uri_for_task,
|
||||
&relative_path,
|
||||
&document_id,
|
||||
);
|
||||
buffer_store_for_task.mark_external_modified(
|
||||
&ws_path,
|
||||
Some("external-editor".into()),
|
||||
);
|
||||
buffer_store_for_task
|
||||
.mark_external_modified(&ws_path, Some("external-editor".into()));
|
||||
}
|
||||
}
|
||||
document_id
|
||||
} else {
|
||||
String::new()
|
||||
};
|
||||
|
||||
let payload = json!({
|
||||
"sourceKind": "local_folder",
|
||||
@@ -279,6 +282,15 @@ fn is_markdown_path(path: &Path) -> bool {
|
||||
}
|
||||
|
||||
fn is_local_search_index_path(path: &Path) -> bool {
|
||||
if path.components().any(|component| {
|
||||
component
|
||||
.as_os_str()
|
||||
.to_str()
|
||||
.map(|value| value == ".mnote")
|
||||
.unwrap_or(false)
|
||||
}) {
|
||||
return false;
|
||||
}
|
||||
if is_markdown_path(path) {
|
||||
return true;
|
||||
}
|
||||
@@ -297,7 +309,27 @@ fn is_local_search_index_path(path: &Path) -> bool {
|
||||
.to_lowercase();
|
||||
matches!(
|
||||
extension.as_str(),
|
||||
"doc" | "docx" | "odt" | "ppt" | "pptx" | "odp" | "xls" | "xlsx" | "ods"
|
||||
"doc"
|
||||
| "docx"
|
||||
| "odt"
|
||||
| "ppt"
|
||||
| "pptx"
|
||||
| "odp"
|
||||
| "xls"
|
||||
| "xlsx"
|
||||
| "ods"
|
||||
| "pdf"
|
||||
| "png"
|
||||
| "jpg"
|
||||
| "jpeg"
|
||||
| "gif"
|
||||
| "webp"
|
||||
| "svg"
|
||||
| "txt"
|
||||
| "log"
|
||||
| "csv"
|
||||
| "json"
|
||||
| "zip"
|
||||
)
|
||||
}
|
||||
|
||||
@@ -430,8 +462,17 @@ mod tests {
|
||||
assert!(is_local_search_index_path(&std::path::Path::new(
|
||||
"office/report.xlsx"
|
||||
)));
|
||||
assert!(is_local_search_index_path(&std::path::Path::new(
|
||||
"attachments/report.pdf"
|
||||
)));
|
||||
assert!(is_local_search_index_path(&std::path::Path::new(
|
||||
"attachments/image.png"
|
||||
)));
|
||||
assert!(!is_local_search_index_path(&std::path::Path::new(
|
||||
"docs/image.png"
|
||||
".mnote/page-options.json"
|
||||
)));
|
||||
assert!(!is_local_search_index_path(&std::path::Path::new(
|
||||
"docs/.DS_Store"
|
||||
)));
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user