MCPcopy Create free account
hub / github.com/acking-you/static_flow / run

Function run

crates/cli/src/commands/sync_notes.rs:55–110  ·  view source on GitHub ↗
(db_path: &Path, dir: &Path, options: SyncNotesOptions)

Source from the content-addressed store, hash-verified

53}
54
55pub async fn run(db_path: &Path, dir: &Path, options: SyncNotesOptions) -> Result<()> {
56 let SyncNotesOptions {
57 recursive,
58 generate_thumbnail,
59 thumbnail_size,
60 language,
61 default_category,
62 default_author,
63 auto_optimize,
64 } = options;
65 let db = connect_db(db_path).await?;
66 let articles_table = ensure_table(&db, "articles", article_schema()).await?;
67 let images_table = ensure_table(&db, "images", image_schema()).await?;
68 let taxonomies_table = ensure_table(&db, "taxonomies", taxonomy_schema()).await?;
69
70 let language = match language.as_deref() {
71 Some("en") => Some(TextEmbeddingLanguage::English),
72 Some("zh") => Some(TextEmbeddingLanguage::Chinese),
73 None => None,
74 Some(value) => anyhow::bail!("unsupported language hint: {value}"),
75 };
76
77 let config = SyncConfig {
78 recursive,
79 generate_thumbnail,
80 thumbnail_size,
81 language,
82 default_category,
83 default_author,
84 };
85
86 let outcome =
87 sync_notes(dir, &articles_table, &images_table, &taxonomies_table, &config).await?;
88
89 if let Err(err) = ensure_vector_index(&articles_table, "vector_en").await {
90 tracing::warn!("Failed to create vector index on articles (vector_en): {err}");
91 }
92 if let Err(err) = ensure_vector_index(&articles_table, "vector_zh").await {
93 tracing::warn!("Failed to create vector index on articles (vector_zh): {err}");
94 }
95 if let Err(err) = ensure_vector_index(&images_table, "vector").await {
96 tracing::warn!("Failed to create vector index on images: {err}");
97 }
98
99 if auto_optimize {
100 if let Err(err) = optimize_table_indexes(&articles_table).await {
101 tracing::warn!("Failed to optimize articles indexes after sync-notes: {err}");
102 }
103 if let Err(err) = optimize_table_indexes(&images_table).await {
104 tracing::warn!("Failed to optimize images indexes after sync-notes: {err}");
105 }
106 }
107
108 tracing::info!("Synced notes: {} articles, {} images.", outcome.articles, outcome.images);
109 Ok(())
110}
111
112async fn sync_notes(

Callers

nothing calls this directly

Calls 8

connect_dbFunction · 0.85
article_schemaFunction · 0.85
image_schemaFunction · 0.85
taxonomy_schemaFunction · 0.85
sync_notesFunction · 0.85
ensure_vector_indexFunction · 0.85
optimize_table_indexesFunction · 0.85
ensure_tableFunction · 0.50

Tested by

no test coverage detected