Commit ba852f8a authored by pyro2927's avatar pyro2927
Browse files

Adding in photo checksum to detect dupes

parent 8e8fd914
......@@ -116,6 +116,15 @@ if (!$result) {
return false;
}
# Add `checksum`
if (!$database->query("SELECT `checksum` FROM `lychee_photos` LIMIT 1;")) {
$result = $database->query("ALTER TABLE `lychee_photos` ADD `checksum` VARCHAR(100) DEFAULT NULL");
if (!$result) {
Log::error($database, 'update_020500', __LINE__, 'Could not update database (' . $database->error . ')');
return false;
}
}
# Reset sorting
$result = $database->query("UPDATE lychee_settings SET value = 'ORDER BY takestamp DESC' WHERE `key` = 'sorting' AND `value` LIKE '%UNIX_TIMESTAMP%';");
if (!$result) {
......
......@@ -130,7 +130,7 @@ class Photo extends Module {
}
# Save to DB
$query = "INSERT INTO lychee_photos (id, title, url, description, tags, type, width, height, size, iso, aperture, make, model, shutter, focal, takestamp, thumbUrl, album, public, star)
$query = "INSERT INTO lychee_photos (id, title, url, description, tags, type, width, height, size, iso, aperture, make, model, shutter, focal, takestamp, thumbUrl, album, public, star, checksum)
VALUES (
'" . $id . "',
'" . $info['title'] . "',
......@@ -151,7 +151,8 @@ class Photo extends Module {
'" . md5($id) . ".jpeg',
'" . $albumID . "',
'" . $public . "',
'" . $star . "');";
'" . $star . "',
'" . md5_file($path) . "');";
$result = $this->database->query($query);
if (!$result) {
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment