Add files now

This commit is contained in:
DariusIII
2017-02-27 14:35:15 +01:00
parent 017a0965c7
commit d9be982571
5 changed files with 37 additions and 35 deletions
+3 -5
View File
@@ -298,12 +298,10 @@ Class NZBContents
$nzbFile = $this->LoadNZB($guid);
if ($nzbFile !== false) {
foreach ($nzbFile->file as $nzbContents) {
if (preg_match('/\.(par[2" ]|\d{2,3}").+\(1\/1\)/i', (string)$nzbContents->attributes()->subject)) {
if ($this->pp->parsePAR2((string)$nzbContents->segments->segment, $relID, $groupID, $this->nntp, $show) === true && $nameStatus === 1) {
$this->pdo->queryExec(sprintf('UPDATE releases SET proc_par2 = 1 WHERE id = %d', $relID));
if ($nameStatus === 1 && $this->pp->parsePAR2((string)$nzbContents->segments->segment, $relID, $groupID, $this->nntp, $show) === true && preg_match('/\.(par[2" ]|\d{2,3}").+\(1\/1\)/i', (string)$nzbContents->attributes()->subject)) {
$this->pdo->queryExec(sprintf('UPDATE releases SET proc_par2 = 1 WHERE id = %d', $relID));
return true;
}
return true;
}
}
}
+17 -4
View File
@@ -71,13 +71,14 @@ class ReleaseFiles
*
* @param int $id The ID of the release.
* @param string $name Name of the file.
* @param int $size Size of the file.
* @param string $hash hash_16k of par2
* @param int $size Size of the file.
* @param int $createdTime Unix time the file was created.
* @param int $hasPassword Does it have a password (see Releases class constants)?
*
* @return mixed
*/
public function add($id, $name, $size, $createdTime, $hasPassword)
public function add($id, $name, $hash = '', $size, $createdTime, $hasPassword)
{
$insert = 0;
@@ -93,18 +94,30 @@ class ReleaseFiles
if ($duplicateCheck === false) {
$insert = $this->pdo->queryInsert(
sprintf("
sprintf('
INSERT INTO release_files
(releases_id, name, size, createddate, passworded)
VALUES
(%d, %s, %s, %s, %d)",
(%d, %s, %s, %s, %s, %d)',
$id,
$this->pdo->escapeString(utf8_encode($name)),
!empty($this->pdo->escapeString($hash)) ?? '',
$this->pdo->escapeString($size),
$this->pdo->from_unixtime($createdTime),
$hasPassword
)
);
$this->pdo->queryExec(
sprintf('
INSERT INTO par_hashes
(releases_id, name, hash)
VALUES (%d, %s, %s)',
$id,
$this->pdo->escapeString(utf8_encode($name)),
!empty($this->pdo->escapeString($hash)) ?? ''
)
);
$this->sphinxSearch->updateRelease($id, $this->pdo);
}
return $insert;
+2 -12
View File
@@ -355,17 +355,7 @@ class PostProcess
$foundName = true;
if (in_array(
(int)$query['categories_id'],
[
Category::BOOKS_UNKNOWN,
Category::GAME_OTHER,
Category::MOVIE_OTHER,
Category::MUSIC_OTHER,
Category::PC_PHONE_OTHER,
Category::TV_OTHER,
Category::OTHER_HASHED,
Category::XXX_OTHER,
Category::OTHER_MISC
]
Category::OTHERS_GROUP
)
) {
$foundName = false;
@@ -417,7 +407,7 @@ class PostProcess
) {
// Try to add the files to the DB.
if ($this->releaseFiles->add($relID, $file['name'], $file['size'], $query['post_date'], 0)) {
if ($this->releaseFiles->add($relID, $file['name'], $file['hash_16K'], $file['size'], $query['post_date'], 0)) {
$filesAdded++;
}
}
+4 -14
View File
@@ -2252,20 +2252,10 @@ class ProcessAdditional
// Only get a new name if the category is OTHER.
$foundName = true;
if (NN_RENAME_PAR2 &&
$releaseInfo['proc_pp'] == 0 &&
$releaseInfo['proc_pp'] === 0 &&
in_array(
((int)$this->_release['categories_id']),
[
Category::BOOKS_UNKNOWN,
Category::GAME_OTHER,
Category::MOVIE_OTHER,
Category::MUSIC_OTHER,
Category::PC_PHONE_OTHER,
Category::TV_OTHER,
Category::OTHER_HASHED,
Category::XXX_OTHER,
Category::OTHER_MISC
]
(int)$this->_release['categories_id'],
Category::OTHERS_GROUP
)
) {
$foundName = false;
@@ -2297,7 +2287,7 @@ class ProcessAdditional
) {
// Try to add the files to the DB.
if ($this->_releaseFiles->add($this->_release['id'], $file['name'], $file['size'], $releaseInfo['postdate'], 0)) {
if ($this->_releaseFiles->add($this->_release['id'], $file['name'], $file['hash_16K'], $file['size'], $releaseInfo['postdate'], 0)) {
$filesAdded++;
}
}
@@ -0,0 +1,11 @@
# Create par_hashes table
DROP TABLE IF EXISTS par_hashes;
CREATE TABLE par_hashes (
releases_id INT(11) NOT NULL COMMENT 'FK to releases.id',
hash VARCHAR(255) NOT NULL DEFAULT '' COMMENT 'hash of first 16k of rar files in par2 file',
PRIMARY KEY (releases_id, hash)
)
ENGINE = MYISAM
DEFAULT CHARSET = utf8
COLLATE = utf8_unicode_ci;