mirror of
https://github.com/Poniverse/Pony.fm.git
synced 2024-11-25 06:27:59 +01:00
Fixed race condition in genre deletion
This commit is contained in:
parent
9e63702387
commit
d7fc5f02cf
1 changed files with 10 additions and 7 deletions
|
@ -63,14 +63,17 @@ class DeleteGenre extends Job implements ShouldQueue
|
||||||
|
|
||||||
// This is done instead of a single UPDATE query in order to
|
// This is done instead of a single UPDATE query in order to
|
||||||
// generate revision logs for the change.
|
// generate revision logs for the change.
|
||||||
$this->genreToDelete->tracks()->each(function ($track) {
|
$tracks = Track::whereGenreId($this->genreToDelete->id)->get();
|
||||||
/** @var Track $track */
|
|
||||||
|
|
||||||
$track->genre_id = $this->destinationGenre->id;
|
|
||||||
$track->save();
|
|
||||||
$track->updateTags();
|
|
||||||
});
|
|
||||||
|
|
||||||
$this->genreToDelete->delete();
|
$this->genreToDelete->delete();
|
||||||
|
$chunks = $tracks->chunk(200);
|
||||||
|
|
||||||
|
foreach ($chunks as $chunk) {
|
||||||
|
foreach ($chunk as $track) {
|
||||||
|
$track->genre_id = $this->destinationGenre->id;
|
||||||
|
$track->save();
|
||||||
|
$track->updateTags();
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue