Adding in photo checksum to detect dupes

This commit is contained in:
pyro2927 2014-07-02 14:29:34 -05:00
parent 8e8fd91497
commit ba852f8a03
2 changed files with 12 additions and 2 deletions

View File

@ -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) {

View File

@ -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) {