diff --git a/Blacklight/Releases.php b/Blacklight/Releases.php index 321a07897..c059285ff 100755 --- a/Blacklight/Releases.php +++ b/Blacklight/Releases.php @@ -19,9 +19,7 @@ class Releases extends Release { // RAR/ZIP Passworded indicator. public const PASSWD_NONE = 0; // No password. - public const PASSWD_POTENTIAL = 1; // Might have a password. - public const BAD_FILE = 2; // Possibly broken RAR/ZIP. - public const PASSWD_RAR = 10; // Definitely passworded. + public const PASSWD_RAR = 1; // Definitely passworded. /** * @var \Blacklight\SphinxSearch @@ -171,17 +169,13 @@ class Releases extends Release public function showPasswords(): ?string { $show = (int) Settings::settingValue('..showpasswordedrelease'); - $setting = $show ?? 10; + $setting = $show ?? 1; switch ($setting) { case 0: // Hide releases with a password or a potential password (Hide unprocessed releases). return '= '.self::PASSWD_NONE; - case 1: // Show releases with no password or a potential password (Show unprocessed releases). - return '<= '.self::PASSWD_POTENTIAL; - case 2: // Hide releases with a password or a potential password (Show unprocessed releases). - return '<= '.self::PASSWD_NONE; - case 10: // Shows everything. + case 1: // Shows everything. default: return '<= '.self::PASSWD_RAR; } diff --git a/Blacklight/libraries/Forking.php b/Blacklight/libraries/Forking.php index 69aefa291..f2e123fde 100755 --- a/Blacklight/libraries/Forking.php +++ b/Blacklight/libraries/Forking.php @@ -702,7 +702,7 @@ class Forking FROM releases r LEFT JOIN categories c ON c.id = r.categories_id WHERE r.nzbstatus = %d - AND r.passwordstatus BETWEEN -6 AND -1 + AND r.passwordstatus = -1 AND r.haspreview = -1 AND c.disablepreview = 0 %s %s diff --git a/Blacklight/processing/ProcessReleases.php b/Blacklight/processing/ProcessReleases.php index 568dafef6..e027a9e5a 100755 --- a/Blacklight/processing/ProcessReleases.php +++ b/Blacklight/processing/ProcessReleases.php @@ -915,15 +915,6 @@ class ProcessReleases } } - // Possibly passworded releases. - if ((int) Settings::settingValue('..deletepossiblerelease') === 1) { - $releases = Release::query()->where('passwordstatus', '=', Releases::PASSWD_POTENTIAL)->select(['id', 'guid'])->get(); - foreach ($releases as $release) { - $this->releases->deleteSingle(['g' => $release->guid, 'i' => $release->id], $this->nzb, $this->releaseImage); - $passwordDeleted++; - } - } - if ((int) $this->crossPostTime !== 0) { // Cross posted releases. $releases = Release::query()->where('adddate', '>', now()->subHours($this->crossPostTime))->havingRaw('COUNT(name) > 1')->groupBy('name')->select(['id', 'guid'])->get(); diff --git a/Blacklight/processing/post/ProcessAdditional.php b/Blacklight/processing/post/ProcessAdditional.php index 58af6f65d..c49ec3574 100755 --- a/Blacklight/processing/post/ProcessAdditional.php +++ b/Blacklight/processing/post/ProcessAdditional.php @@ -626,7 +626,7 @@ class ProcessAdditional { $releasesQuery = Release::query() ->where('releases.nzbstatus', '=', 1) - ->whereBetween('releases.passwordstatus', [-6, -1]) + ->where('releases.passwordstatus', '=', -1) ->where('releases.haspreview', '=', -1) ->where('categories.disablepreview', '=', 0); if ($this->_maxSize > 0) { @@ -774,7 +774,9 @@ class ProcessAdditional /** * Create a temporary storage folder for the current release. * + * * @return bool + * @throws \Exception */ protected function _createTempFolder(): bool { @@ -784,7 +786,7 @@ class ProcessAdditional if (! File::makeDirectory($this->tmpPath, 0777, true, false) && ! File::isDirectory($this->tmpPath)) { $this->_echo('Unable to create directory: '.$this->tmpPath, 'warning'); - return $this->_decrementPasswordStatus(); + return $this->_deleteRelease(); } } @@ -803,14 +805,14 @@ class ProcessAdditional if ($nzbPath === false) { $this->_echo('NZB not found for GUID: '.$this->_release->guid, 'warning'); - $this->_decrementPasswordStatus(); + $this->_deleteRelease(); } $nzbContents = Utility::unzipGzipFile($nzbPath); if (! $nzbContents) { $this->_echo('NZB is empty or broken for GUID: '.$this->_release->guid, 'warning'); - $this->_decrementPasswordStatus(); + $this->_deleteRelease(); } // Get a list of files in the nzb. @@ -818,7 +820,7 @@ class ProcessAdditional if (\count($this->_nzbContents) === 0) { $this->_echo('NZB is potentially broken for GUID: '.$this->_release->guid, 'warning'); - $this->_decrementPasswordStatus(); + $this->_deleteRelease(); } // Sort keys. ksort($this->_nzbContents, SORT_NATURAL); @@ -826,18 +828,6 @@ class ProcessAdditional return true; } - /** - * Decrement password status for the current release. - * - * @return false - */ - protected function _decrementPasswordStatus(): bool - { - Release::whereId($this->_release->id)->decrement('passwordstatus'); - - return false; - } - /** * @return bool * @throws \Exception @@ -1157,7 +1147,7 @@ class ProcessAdditional if ($this->_innerFileBlacklist !== false && preg_match($this->_innerFileBlacklist, $file['name'])) { $this->_releaseHasPassword = true; - $this->_passwordStatus = [Releases::PASSWD_POTENTIAL]; + $this->_passwordStatus = [Releases::PASSWD_RAR]; break; } @@ -1230,7 +1220,7 @@ class ProcessAdditional $this->_debug('Codec spam found, setting release to potentially passworded.'); } $this->_releaseHasPassword = true; - $this->_passwordStatus = [Releases::PASSWD_POTENTIAL]; + $this->_passwordStatus = [Releases::PASSWD_RAR]; } //Run a PreDB filename check on insert to try and match the release elseif ($file['name'] !== '' && strpos($file['name'], '.') !== 0) { $this->_release['filename'] = $file['name']; diff --git a/Changelog b/Changelog index 559ba5b2a..d0a06929a 100755 --- a/Changelog +++ b/Changelog @@ -1,4 +1,5 @@ 2019-08-20 DariusIII + * Chg: Change used passwordstatus for releases * Chg: Update tinyMCE to latest version 2019-08-19 DariusIII * Chg: Use insertOnDuplicateKey trait in ReleaseFile class diff --git a/database/migrations/2019_08_20_141217_update_releases_table.php b/database/migrations/2019_08_20_141217_update_releases_table.php new file mode 100644 index 000000000..5b3eaecef --- /dev/null +++ b/database/migrations/2019_08_20_141217_update_releases_table.php @@ -0,0 +1,32 @@ +smallInteger('passwordstatus')->default(-1)->change(); + }); + } + + /** + * Reverse the migrations. + * + * @return void + */ + public function down() + { + Schema::table('releases', function (Blueprint $table) { + $table->boolean('passwordstatus')->default(0)->change(); + }); + } +} diff --git a/resources/views/themes/Gentele/search.tpl b/resources/views/themes/Gentele/search.tpl index 12663860f..5cbf597a5 100755 --- a/resources/views/themes/Gentele/search.tpl +++ b/resources/views/themes/Gentele/search.tpl @@ -233,14 +233,6 @@