db: improve content hashing; cache only positive scan result

Signed-off-by: NotAShelf <raf@notashelf.dev>
Change-Id: If8035bf1dcd598a992762b9c714253406a6a6964
This commit is contained in:
raf 2026-03-05 14:27:10 +03:00
commit 373affabee
Signed by: NotAShelf
GPG key ID: 29D95B64378DB4BF
4 changed files with 115 additions and 19 deletions

View file

@ -363,6 +363,8 @@ impl WatchCommand for SqliteClipboardDb {
if last_hash != Some(current_hash) {
// Clone buf for the async operation since it needs 'static
let buf_clone = buf.clone();
#[allow(clippy::cast_possible_wrap)]
let content_hash = Some(current_hash as i64);
match async_db
.store_entry(
buf_clone,
@ -371,6 +373,7 @@ impl WatchCommand for SqliteClipboardDb {
Some(excluded_apps.to_vec()),
min_size,
max_size,
content_hash,
)
.await
{
@ -433,7 +436,7 @@ impl WatchCommand for SqliteClipboardDb {
}
}
/// Unit-testable helper: given ordered offers and a preference, return the
/// Given ordered offers and a preference, return the
/// chosen MIME type. This mirrors the selection logic in
/// [`negotiate_mime_type`] without requiring a Wayland connection.
#[cfg(test)]