fix: order torrent creation from most to least important

This commit is contained in:
Roardom
2024-12-01 19:51:20 +00:00
parent fdffaa383a
commit e7c369002e
2 changed files with 50 additions and 42 deletions
+18 -14
View File
@@ -323,20 +323,6 @@ class TorrentController extends BaseController
// Populate the status/seeders/leechers/times_completed fields for the external tracker
$torrent->refresh();
Unit3dAnnounce::addTorrent($torrent);
if ($torrent->getAttribute('featured')) {
Unit3dAnnounce::addFeaturedTorrent($torrent->id);
}
// Set torrent to featured
if ($torrent->getAttribute('featured')) {
$featuredTorrent = new FeaturedTorrent();
$featuredTorrent->user_id = $user->id;
$featuredTorrent->torrent_id = $torrent->id;
$featuredTorrent->save();
}
// Backup the files contained in the torrent
$files = TorrentTools::getTorrentFiles($decodedTorrent);
@@ -350,6 +336,24 @@ class TorrentController extends BaseController
TorrentFile::insert($files->toArray());
}
// Set torrent to featured
if ($torrent->getAttribute('featured')) {
$featuredTorrent = new FeaturedTorrent();
$featuredTorrent->user_id = $user->id;
$featuredTorrent->torrent_id = $torrent->id;
$featuredTorrent->save();
}
// Tracker updates come after database updates in case tracker's offline
Unit3dAnnounce::addTorrent($torrent);
if ($torrent->getAttribute('featured')) {
Unit3dAnnounce::addFeaturedTorrent($torrent->id);
}
// TMDB updates come after tracker updates in case TMDB's offline
$tmdbScraper = new TMDBScraper();
if ($torrent->category->tv_meta && $torrent->tmdb) {
+32 -28
View File
@@ -415,12 +415,6 @@ class TorrentController extends Controller
// Populate the status/seeders/leechers/times_completed fields for the external tracker
$torrent->refresh();
Unit3dAnnounce::addTorrent($torrent);
if ($torrent->getAttribute('featured')) {
Unit3dAnnounce::addFeaturedTorrent($torrent->id);
}
$category = Category::findOrFail($request->integer('category_id'));
// Backup the files contained in the torrent
@@ -436,6 +430,38 @@ class TorrentController extends Controller
TorrentFile::insert($files->toArray());
}
// Cover Image for No-Meta Torrents
if ($request->hasFile('torrent-cover')) {
$image_cover = $request->file('torrent-cover');
abort_if(\is_array($image_cover), 400);
$filename_cover = 'torrent-cover_'.$torrent->id.'.jpg';
$path_cover = public_path('/files/img/'.$filename_cover);
Image::make($image_cover->getRealPath())->fit(400, 600)->encode('jpg', 90)->save($path_cover);
}
// Banner Image for No-Meta Torrents
if ($request->hasFile('torrent-banner')) {
$image_cover = $request->file('torrent-banner');
abort_if(\is_array($image_cover), 400);
$filename_cover = 'torrent-banner_'.$torrent->id.'.jpg';
$path_cover = public_path('/files/img/'.$filename_cover);
Image::make($image_cover->getRealPath())->fit(960, 540)->encode('jpg', 90)->save($path_cover);
}
// Tracker updates come after initial database updates in case tracker's offline
Unit3dAnnounce::addTorrent($torrent);
if ($torrent->getAttribute('featured')) {
Unit3dAnnounce::addFeaturedTorrent($torrent->id);
}
// TMDB updates come after tracker updates in case TMDB's offline
// TMDB Meta
if ($torrent->tmdb != 0) {
switch (true) {
@@ -461,28 +487,6 @@ class TorrentController extends Controller
Keyword::upsert($keywords->toArray(), ['torrent_id', 'name']);
}
// Cover Image for No-Meta Torrents
if ($request->hasFile('torrent-cover')) {
$image_cover = $request->file('torrent-cover');
abort_if(\is_array($image_cover), 400);
$filename_cover = 'torrent-cover_'.$torrent->id.'.jpg';
$path_cover = public_path('/files/img/'.$filename_cover);
Image::make($image_cover->getRealPath())->fit(400, 600)->encode('jpg', 90)->save($path_cover);
}
// Banner Image for No-Meta Torrents
if ($request->hasFile('torrent-banner')) {
$image_cover = $request->file('torrent-banner');
abort_if(\is_array($image_cover), 400);
$filename_cover = 'torrent-banner_'.$torrent->id.'.jpg';
$path_cover = public_path('/files/img/'.$filename_cover);
Image::make($image_cover->getRealPath())->fit(960, 540)->encode('jpg', 90)->save($path_cover);
}
// check for trusted user and update torrent
if ($user->group->is_trusted && !$request->boolean('mod_queue_opt_in')) {
$appurl = config('app.url');