[bulk_add_csv] add each image in a transaction, fixes #1015
This commit is contained in:
parent
2667d635ad
commit
9ddd43d720
1 changed files with 14 additions and 15 deletions
|
@ -53,24 +53,23 @@ class BulkAddCSV extends Extension
|
||||||
*/
|
*/
|
||||||
private function add_image(string $tmpname, string $filename, array $tags, string $source, string $rating, string $thumbfile)
|
private function add_image(string $tmpname, string $filename, array $tags, string $source, string $rating, string $thumbfile)
|
||||||
{
|
{
|
||||||
$event = send_event(new DataUploadEvent($tmpname, [
|
global $database;
|
||||||
'filename' => pathinfo($filename, PATHINFO_BASENAME),
|
$database->with_savepoint(function () use ($tmpname, $filename, $tags, $source, $rating, $thumbfile) {
|
||||||
'tags' => $tags,
|
$event = send_event(new DataUploadEvent($tmpname, [
|
||||||
'source' => $source,
|
'filename' => pathinfo($filename, PATHINFO_BASENAME),
|
||||||
]));
|
'tags' => $tags,
|
||||||
|
'source' => $source,
|
||||||
|
'rating' => $rating,
|
||||||
|
]));
|
||||||
|
|
||||||
if (count($event->images) == 0) {
|
if (count($event->images) == 0) {
|
||||||
throw new UploadException("File type not recognised");
|
throw new UploadException("File type not recognised");
|
||||||
} else {
|
} else {
|
||||||
if (class_exists("Shimmie2\RatingSetEvent") && in_array($rating, ["s", "q", "e"])) {
|
if (file_exists($thumbfile)) {
|
||||||
foreach($event->images as $image) {
|
copy($thumbfile, warehouse_path(Image::THUMBNAIL_DIR, $event->hash));
|
||||||
send_event(new RatingSetEvent($image, $rating));
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (file_exists($thumbfile)) {
|
});
|
||||||
copy($thumbfile, warehouse_path(Image::THUMBNAIL_DIR, $event->hash));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private function add_csv(string $csvfile)
|
private function add_csv(string $csvfile)
|
||||||
|
|
Reference in a new issue