From 99c22095f903ac10a80ffaf0be03fdc3db410a07 Mon Sep 17 00:00:00 2001 From: Fijxu Date: Thu, 21 Nov 2024 03:23:29 -0300 Subject: [PATCH] 0.9.3.2: Delete entry from the DB is the file doesn't exists on the filesystem --- config/config.example.yml | 2 +- src/utils.cr | 2 ++ 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/config/config.example.yml b/config/config.example.yml index 7b3ee68..18f9602 100644 --- a/config/config.example.yml +++ b/config/config.example.yml @@ -2,7 +2,7 @@ colorize_logs: true files: "./files" thumbnails: "./thumbnails" generateThumbnails: true -db: "./db.sqlite3" +db: "./db/db.sqlite3" adminEnabled: true adminApiKey: "asd" fileameLength: 3 diff --git a/src/utils.cr b/src/utils.cr index cbd6fb9..499c651 100644 --- a/src/utils.cr +++ b/src/utils.cr @@ -60,6 +60,8 @@ module Utils SQL.exec "DELETE FROM files WHERE filename = ?", file[:filename] rescue ex LOGGER.error "#{ex.message}" + # Also delete the file entry from the DB if it doesn't exist. + SQL.exec "DELETE FROM files WHERE filename = ?", file[:filename] end end end