chg: Added some checks during deletion of a shortlink

This commit is contained in:
SinTan1729
2024-03-13 18:59:10 -05:00
parent aa097ad982
commit 5ecd29926d
3 changed files with 16 additions and 5 deletions

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 {