mirror of
https://github.com/NotAShelf/stash.git
synced 2026-04-12 22:17:41 +00:00
stash: don't initialize watch daemon with None
Fixes the daemon always updating the latest entry. Signed-off-by: NotAShelf <raf@notashelf.dev> Change-Id: I6a6a696489a2e9a0928ff799a4210c160014c485
This commit is contained in:
parent
6c5408abd1
commit
5bcc23b6f9
1 changed files with 16 additions and 1 deletions
17
src/main.rs
17
src/main.rs
|
|
@ -101,7 +101,22 @@ fn report_error<T>(result: Result<T, impl std::fmt::Display>, context: &str) ->
|
|||
async fn run_daemon(db: &db::SqliteClipboardDb, max_dedupe_search: u64, max_items: u64) {
|
||||
log::info!("Starting clipboard watch daemon");
|
||||
|
||||
let mut last_contents: Option<Vec<u8>> = None;
|
||||
// Initialize with current clipboard to avoid duplicating on startup
|
||||
let mut last_contents: Option<Vec<u8>> = match get_contents(
|
||||
ClipboardType::Regular,
|
||||
Seat::Unspecified,
|
||||
wl_clipboard_rs::paste::MimeType::Any,
|
||||
) {
|
||||
Ok((mut reader, _)) => {
|
||||
let mut buf = Vec::new();
|
||||
if reader.read_to_end(&mut buf).is_ok() && !buf.is_empty() {
|
||||
Some(buf)
|
||||
} else {
|
||||
None
|
||||
}
|
||||
}
|
||||
Err(_) => None,
|
||||
};
|
||||
|
||||
loop {
|
||||
match get_contents(
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue