@@ -45,7 +45,7 @@ pub fn open() -> Connection {
4545/// * `entry` - The `RsyncTrack` data to persist.
4646pub fn upsert ( conn : & Connection , hash : & str , entry : & RsyncTrack ) {
4747 let ( status, progress) = encode_status ( & entry. status ) ;
48- conn. execute (
48+ match conn. execute (
4949 "INSERT OR REPLACE INTO state
5050 (hash, name, status, progress, url, save_path, remote_host, remote_user, remote_path, delete_after_copy)
5151 VALUES (?1, ?2, ?3, ?4, ?5, ?6, ?7, ?8, ?9, ?10)" ,
@@ -61,8 +61,12 @@ pub fn upsert(conn: &Connection, hash: &str, entry: &RsyncTrack) {
6161 entry. put_item. remote_path,
6262 entry. put_item. delete_after_copy as i32 ,
6363 ] ,
64- )
65- . expect ( "Failed to upsert state" ) ;
64+ ) {
65+ Ok ( _) => ( ) ,
66+ Err ( e) => {
67+ log:: error!( "Failed to upsert state for {}: {}" , hash, e) ;
68+ }
69+ }
6670}
6771
6872/// Inserts or replaces a pending transfer entry in the `pending` table.
@@ -73,7 +77,7 @@ pub fn upsert(conn: &Connection, hash: &str, entry: &RsyncTrack) {
7377/// * `tag` - Unique identifier for the pending item.
7478/// * `item` - The `PutItem` data to store as pending.
7579pub fn upsert_pending ( conn : & Connection , tag : & str , item : & PutItem ) {
76- conn. execute (
80+ match conn. execute (
7781 "INSERT OR REPLACE INTO pending
7882 (tag, url, save_path, remote_host, remote_user, remote_path, delete_after_copy)
7983 VALUES (?1, ?2, ?3, ?4, ?5, ?6, ?7)" ,
@@ -86,8 +90,12 @@ pub fn upsert_pending(conn: &Connection, tag: &str, item: &PutItem) {
8690 item. remote_path,
8791 item. delete_after_copy as i32 ,
8892 ] ,
89- )
90- . expect ( "Failed to upsert pending" ) ;
93+ ) {
94+ Ok ( _) => ( ) ,
95+ Err ( e) => {
96+ log:: error!( "Failed to upsert pending for {:?}: {}" , item. hash, e) ;
97+ }
98+ }
9199}
92100
93101/// Removes a pending transfer entry by its tag.
@@ -97,8 +105,12 @@ pub fn upsert_pending(conn: &Connection, tag: &str, item: &PutItem) {
97105/// * `conn` - Active SQLite database connection.
98106/// * `tag` - Identifier of the pending entry to remove.
99107pub fn remove_pending ( conn : & Connection , tag : & str ) {
100- conn. execute ( "DELETE FROM pending WHERE tag = ?1" , params ! [ tag] )
101- . expect ( "Failed to remove pending" ) ;
108+ match conn. execute ( "DELETE FROM pending WHERE tag = ?1" , params ! [ tag] ) {
109+ Ok ( _) => ( ) ,
110+ Err ( e) => {
111+ log:: error!( "Failed to remove pending for {}: {}" , tag, e) ;
112+ }
113+ }
102114}
103115
104116/// Loads all pending transfer entries from the database into memory.
@@ -142,8 +154,12 @@ pub fn load_pending(conn: &Connection) -> HashMap<String, PutItem> {
142154/// * `conn` - Active SQLite database connection.
143155/// * `hash` - Unique torrent hash identifier.
144156pub fn remove ( conn : & Connection , hash : & str ) {
145- conn. execute ( "DELETE FROM state WHERE hash = ?1" , params ! [ hash] )
146- . expect ( "Failed to remove state" ) ;
157+ match conn. execute ( "DELETE FROM state WHERE hash = ?1" , params ! [ hash] ) {
158+ Ok ( _) => ( ) ,
159+ Err ( e) => {
160+ log:: error!( "Failed to remove for {}: {}" , hash, e) ;
161+ }
162+ }
147163}
148164
149165/// Loads all pending transfer entries from the database into memory.
0 commit comments