db: treat valid UTF-8 entries as text/plain

Makes JSON output more... servicable.

Signed-off-by: NotAShelf <raf@notashelf.dev>
Change-Id: I6a6a6964f642a02e990979f93f53a8b69764b469
This commit is contained in:
raf 2025-08-12 23:00:18 +03:00
commit 9d0ad95e07
Signed by: NotAShelf
GPG key ID: 29D95B64378DB4BF

View file

@ -165,7 +165,17 @@ impl ClipboardDb for SqliteClipboardDb {
return Err(StashError::AllWhitespace);
}
let mime = detect_mime(&buf);
let mime = match detect_mime(&buf) {
None => {
// If valid UTF-8, treat as text/plain
if std::str::from_utf8(&buf).is_ok() {
Some("text/plain".to_string())
} else {
None
}
}
other => other,
};
self.deduplicate(&buf, max_dedupe_search)?;