chg: Added some checks during deletion of a shortlink

This commit is contained in:
SinTan1729 committed 2024-03-13 18:59:10 -05:00
1 parent aa097ad982
commit 5ecd29926d
3 files changed
+16 -5

No files matched your search

+3 -3
View File
@@ -49,9 +49,9 @@ pub fn add_link(shortlink: String, longlink: String, db: &Connection) -> bool {
.is_ok()
}
pub fn delete_link(shortlink: String, db: &Connection) {
db.execute("DELETE FROM urls WHERE short_url = ?1", [shortlink])
.unwrap();
pub fn delete_link(shortlink: String, db: &Connection) -> bool {
let out = db.execute("DELETE FROM urls WHERE short_url = ?1", [shortlink]);
out.is_ok() && (out.unwrap() > 0)
}
pub fn open_db(path: String) -> Connection {