MCPcopy Create free account
hub / github.com/chatmail/core / maybe_add_from_param

Function maybe_add_from_param

src/sql.rs:1112–1139  ·  view source on GitHub ↗
(
    sql: &Sql,
    files_in_use: &mut HashSet<String>,
    query: &str,
    param_id: Param,
)

Source from the content-addressed store, hash-verified

1110}
1111
1112async fn maybe_add_from_param(
1113 sql: &Sql,
1114 files_in_use: &mut HashSet<String>,
1115 query: &str,
1116 param_id: Param,
1117) -> Result<()> {
1118 sql.query_map(
1119 query,
1120 (),
1121 |row| {
1122 let row: String = row.get(0)?;
1123 Ok(row)
1124 },
1125 |rows| {
1126 for row in rows {
1127 let param: Params = row?.parse().unwrap_or_default();
1128 if let Some(file) = param.get(param_id) {
1129 maybe_add_file(files_in_use, file);
1130 }
1131 }
1132 Ok(())
1133 },
1134 )
1135 .await
1136 .context(format!("housekeeping: failed to add_from_param {query}"))?;
1137
1138 Ok(())
1139}
1140
1141/// Removes from the database stale locally deleted messages that also don't
1142/// have a server UID.

Callers 1

remove_unused_filesFunction · 0.85

Calls 4

maybe_add_fileFunction · 0.85
query_mapMethod · 0.80
parseMethod · 0.80
getMethod · 0.45

Tested by

no test coverage detected