Fixes for fopen and fileperm stat errors in additional postprocessing.

This commit is contained in:
DariusIII
2015-03-02 22:42:13 +01:00
parent f7e6cd7f7d
commit ca08da213f
5 changed files with 37 additions and 46 deletions
+27 -29
View File
@@ -691,15 +691,7 @@ Class ProcessAdditional
if (!is_dir($this->tmpPath)) {
$this->_echo('Unable to create directory: ' . $this->tmpPath, 'warning');
// Decrement password status.
$this->pdo->queryExec(
sprintf(
'UPDATE releases SET passwordstatus = passwordstatus - 1 WHERE ID = %d',
$this->_release['ID']
)
);
return false;
return $this->_decrementPasswordStatus();
}
}
return true;
@@ -716,41 +708,47 @@ Class ProcessAdditional
if ($nzbPath === false) {
$this->_echo('NZB not found for GUID: ' . $this->_release['guid'], 'warning');
// The nzb was not located. decrement the password status.
$this->pdo->queryExec(
sprintf(
'UPDATE releases SET passwordstatus = passwordstatus - 1 WHERE ID = %d',
$this->_release['ID']
)
);
return false;
return $this->_decrementPasswordStatus();
}
$nzbContents = Utility::unzipGzipFile($nzbPath);
if (!$nzbContents) {
$this->_echo('NZB is empty or broken for GUID: ' . $this->_release['guid'], 'warning');
return $this->_decrementPasswordStatus();
}
// Get a list of files in the nzb.
$this->_nzbContents = $this->_nzb->nzbFileList($nzbContents);
if (count($this->_nzbContents) === 0) {
$this->_echo('NZB is empty or broken for GUID: ' . $this->_release['guid'], 'warning');
// There does not appear to be any files in the nzb, decrement password status.
$this->pdo->queryExec(
sprintf(
'UPDATE releases SET passwordstatus = passwordstatus - 1 WHERE ID = %d',
$this->_release['ID']
)
);
return false;
$this->_echo('NZB is potentially broken for GUID: ' . $this->_release['guid'], 'warning');
return $this->_decrementPasswordStatus();
}
// Sort the files inside the NZB.
usort($this->_nzbContents, ['ProcessAdditional', '_sortNZB']);
usort($this->_nzbContents, ['\tmux\lib\ProcessAdditional', '_sortNZB']);
return true;
}
/**
* Decrement password status for the current release.
*
* @param bool $return Return value.
*
* @return bool
*/
protected function _decrementPasswordStatus($return = false)
{
$this->pdo->queryExec(
sprintf(
'UPDATE releases SET passwordstatus = passwordstatus - 1 WHERE ID = %d',
$this->_release['ID']
)
);
return $return;
}
/**
* Current file we are working on inside a NZB.
* @var array