|
|
|
@ -210,12 +210,15 @@ class Photo extends Module {
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private function exists($checksum) {
|
|
|
|
|
private function exists($checksum, $photoID = null) {
|
|
|
|
|
|
|
|
|
|
# Check dependencies
|
|
|
|
|
self::dependencies(isset($this->database, $checksum));
|
|
|
|
|
|
|
|
|
|
$query = "SELECT id, url, thumbUrl FROM lychee_photos WHERE checksum = '$checksum' LIMIT 1;";
|
|
|
|
|
# Exclude $photoID from select when $photoID is set
|
|
|
|
|
if (isset($photoID)) $query = "SELECT id, url, thumbUrl FROM lychee_photos WHERE checksum = '$checksum' AND id <> '$photoID' LIMIT 1;";
|
|
|
|
|
else $query = "SELECT id, url, thumbUrl FROM lychee_photos WHERE checksum = '$checksum' LIMIT 1;";
|
|
|
|
|
|
|
|
|
|
$result = $this->database->query($query);
|
|
|
|
|
|
|
|
|
|
if (!$result) {
|
|
|
|
@ -820,7 +823,7 @@ class Photo extends Module {
|
|
|
|
|
$this->plugins(__METHOD__, 0, func_get_args());
|
|
|
|
|
|
|
|
|
|
# Get photos
|
|
|
|
|
$photos = $this->database->query("SELECT id, url, thumbUrl FROM lychee_photos WHERE id IN ($this->photoIDs);");
|
|
|
|
|
$photos = $this->database->query("SELECT id, url, thumbUrl, checksum FROM lychee_photos WHERE id IN ($this->photoIDs);");
|
|
|
|
|
if (!$photos) {
|
|
|
|
|
Log::error($this->database, __METHOD__, __LINE__, $this->database->error);
|
|
|
|
|
return false;
|
|
|
|
@ -829,6 +832,10 @@ class Photo extends Module {
|
|
|
|
|
# For each photo
|
|
|
|
|
while ($photo = $photos->fetch_object()) {
|
|
|
|
|
|
|
|
|
|
# Check if other photos are referring to this images
|
|
|
|
|
# If so, only delete the db entry
|
|
|
|
|
if ($this->exists($photo->checksum, $photo->id)===false) {
|
|
|
|
|
|
|
|
|
|
# Get retina thumb url
|
|
|
|
|
$thumbUrl2x = explode(".", $photo->thumbUrl);
|
|
|
|
|
$thumbUrl2x = $thumbUrl2x[0] . '@2x.' . $thumbUrl2x[1];
|
|
|
|
@ -851,6 +858,8 @@ class Photo extends Module {
|
|
|
|
|
return false;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
# Delete db entry
|
|
|
|
|
$delete = $this->database->query("DELETE FROM lychee_photos WHERE id = '$photo->id';");
|
|
|
|
|
if (!$delete) {
|
|
|
|
|