Small improvements in additional processing.

This commit is contained in:
DariusIII
2016-05-09 22:10:59 +02:00
parent 1810579a9d
commit 92bc3c8f34
5 changed files with 66 additions and 12 deletions
+40 -3
View File
@@ -209,6 +209,11 @@ class ProcessAdditional
*/
protected $_nfo;
/**
* @var \newznab\processing\post\CRC
*/
protected $_crc;
/**
* @var bool
*/
@@ -381,6 +386,17 @@ class ProcessAdditional
*/
protected $_compressedFilesChecked;
/**
* Should we download the last rar?
* @var bool
*/
protected $_fetchLastFiles;
/**
* Are we downloading the last rar?
* @var bool
*/
protected $_reverse;
/**
* @param array $options Class instances / echo to cli.
*/
@@ -420,10 +436,14 @@ class ProcessAdditional
$this->_srrInfo = new \SrrInfo();
$this->_nfo = ($options['Nfo'] instanceof Nfo ? $options['Nfo'] : new Nfo(['Echo' => $this->_echoCLI, 'Settings' => $this->pdo]));
$this->sphinx = ($options['SphinxSearch'] instanceof SphinxSearch ? $options['SphinxSearch'] : new SphinxSearch());
if (class_exists('newznab\processing\post\CRC')) {
$this->_crc = new CRC(['Settings' => $this->pdo, 'Echo' => $this->_echoCLI, 'NameFixer' => $this->_nameFixer]);
}
$this->_innerFileBlacklist = ($this->pdo->getSetting('innerfileblacklist') == '' ? false : $this->pdo->getSetting('innerfileblacklist'));
$this->_maxNestedLevels = ($this->pdo->getSetting('maxnestedlevels') == 0 ? 3 : $this->pdo->getSetting('maxnestedlevels'));
$this->_extractUsingRarInfo = ($this->pdo->getSetting('extractusingrarinfo') == 0 ? false : true);
$this->_fetchLastFiles = ($this->pdo->getSetting('fetchlastcompressedfiles') == 0 ? false : true);
$this->_7zipPath = false;
$this->_unrarPath = false;
@@ -626,7 +646,9 @@ class ProcessAdditional
$this->_releases = $this->pdo->query(
sprintf(
'
SELECT r.id, r.guid, r.name, c.disablepreview, r.size, r.groupid, r.nfostatus, r.completion, r.categories_id, r.searchname, r.preid
SELECT r.id, r.id AS releaseid, r.guid, r.name, r.size, r.groupid,
r.nfostatus, r.completion, r.categories_id, r.searchname, r.preid,
c.disablepreview
FROM releases r
LEFT JOIN categories c ON c.id = r.categories_id
WHERE r.nzbstatus = 1
@@ -729,7 +751,7 @@ class ProcessAdditional
$this->_processNZBCompressedFiles();
// Download rar/zip in reverse order, to get the last rar or zip file.
if ($this->pdo->getSetting('fetchlastcompressedfiles') == 1) {
if ($this->_fetchLastFiles == 1) {
$this->_processNZBCompressedFiles(true);
}
@@ -981,7 +1003,8 @@ class ProcessAdditional
*/
protected function _processNZBCompressedFiles($reverse = false)
{
if ($reverse) {
$this->_reverse = $reverse;
if ($this->_reverse) {
if (!krsort($this->_nzbContents)) {
return;
}
@@ -1098,6 +1121,20 @@ class ProcessAdditional
return false;
}
if (isset($this->_crc) && $this->_reverse === true) {
$fileData = (isset($dataSummary['file_list'][0]) ? $dataSummary['file_list'][0] : '');
if(isset($fileData['crc32']) && isset($fileData['size']) && $fileData['size'] > 104857600) {
$matchedCRC = $this->_crc->checkCRCInfo(
$this->_release,
$fileData['crc32'],
$fileData['size'],
'',
$fileData['date']
);
$this->_release['preid'] = ($matchedCRC !== false ? $matchedCRC : 0);
}
}
switch ($dataSummary['main_type']) {
case \ArchiveInfo::TYPE_RAR:
if ($this->_echoCLI) {