mirror of
https://github.com/NotAShelf/stash.git
synced 2026-05-08 16:35:12 +00:00
various: validate lower and upper boundaries before storing; add CLI flags
Signed-off-by: NotAShelf <raf@notashelf.dev> Change-Id: I6484f9579a8799d952b15adcb47c8eec6a6a6964
This commit is contained in:
parent
02ba05dc95
commit
3a14860ae1
4 changed files with 68 additions and 33 deletions
|
|
@ -2,6 +2,7 @@ use std::io::Read;
|
|||
|
||||
use crate::db::{ClipboardDb, SqliteClipboardDb};
|
||||
|
||||
#[allow(clippy::too_many_arguments)]
|
||||
pub trait StoreCommand {
|
||||
fn store(
|
||||
&self,
|
||||
|
|
@ -10,6 +11,8 @@ pub trait StoreCommand {
|
|||
max_items: u64,
|
||||
state: Option<String>,
|
||||
excluded_apps: &[String],
|
||||
min_size: Option<usize>,
|
||||
max_size: usize,
|
||||
) -> Result<(), crate::db::StashError>;
|
||||
}
|
||||
|
||||
|
|
@ -21,6 +24,8 @@ impl StoreCommand for SqliteClipboardDb {
|
|||
max_items: u64,
|
||||
state: Option<String>,
|
||||
excluded_apps: &[String],
|
||||
min_size: Option<usize>,
|
||||
max_size: usize,
|
||||
) -> Result<(), crate::db::StashError> {
|
||||
if let Some("sensitive" | "clear") = state.as_deref() {
|
||||
self.delete_last()?;
|
||||
|
|
@ -31,6 +36,8 @@ impl StoreCommand for SqliteClipboardDb {
|
|||
max_dedupe_search,
|
||||
max_items,
|
||||
Some(excluded_apps),
|
||||
min_size,
|
||||
max_size,
|
||||
)?;
|
||||
log::info!("Entry stored");
|
||||
}
|
||||
|
|
|
|||
|
|
@ -175,6 +175,7 @@ fn negotiate_mime_type(
|
|||
}
|
||||
}
|
||||
|
||||
#[allow(clippy::too_many_arguments)]
|
||||
pub trait WatchCommand {
|
||||
fn watch(
|
||||
&self,
|
||||
|
|
@ -183,6 +184,8 @@ pub trait WatchCommand {
|
|||
excluded_apps: &[String],
|
||||
expire_after: Option<Duration>,
|
||||
mime_type_preference: &str,
|
||||
min_size: Option<usize>,
|
||||
max_size: usize,
|
||||
);
|
||||
}
|
||||
|
||||
|
|
@ -194,6 +197,8 @@ impl WatchCommand for SqliteClipboardDb {
|
|||
excluded_apps: &[String],
|
||||
expire_after: Option<Duration>,
|
||||
mime_type_preference: &str,
|
||||
min_size: Option<usize>,
|
||||
max_size: usize,
|
||||
) {
|
||||
smol::block_on(async {
|
||||
log::info!(
|
||||
|
|
@ -349,6 +354,8 @@ impl WatchCommand for SqliteClipboardDb {
|
|||
max_dedupe_search,
|
||||
max_items,
|
||||
Some(excluded_apps),
|
||||
min_size,
|
||||
max_size,
|
||||
) {
|
||||
Ok(id) => {
|
||||
log::info!("Stored new clipboard entry (id: {id})");
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue