diff --git a/Changelog b/Changelog index 34388845d..fdd953346 100755 --- a/Changelog +++ b/Changelog @@ -1,4 +1,5 @@ 2016-08-22 DariusIII + * Chg: Update NameFixer to use FULLTEXT search in matchPreDbFiles function * Chg: Add FULLTEXT index to predb.filename 2016-08-21 DariusIII * Chg: Remove match_prefiles from tmux, should be ran manualy diff --git a/nntmux/NameFixer.php b/nntmux/NameFixer.php index 0fc4fc235..51ed6f10a 100755 --- a/nntmux/NameFixer.php +++ b/nntmux/NameFixer.php @@ -947,16 +947,25 @@ class NameFixer $matching = 0; $this->_fileName = $this->_cleanMatchFiles($release['filename']); $pre = false; + $preMatch = preg_match('/(\d{2}\.\d{2}\.\d{2})+[\w-.]+[\w]$/i', $this->_fileName, $match); + if($preMatch) { + $result = $this->pdo->queryOneRow(sprintf("SELECT filename AS filename FROM predb WHERE MATCH(filename) AGAINST ('$match[0]' IN BOOLEAN MODE)")); + $preFTmatch = preg_match('/(\d{2}\.\d{2}\.\d{2})+[\w-.]+[\w]$/i', $result['filename'], $match1); + if($preFTmatch) { + if ($match[0] == $match1[0]) { + $this->_fileName = $result['filename']; + } + } + } if ($this->_fileName !== '') { $pre = $this->pdo->queryOneRow( sprintf(' SELECT id AS predb_id, title, source FROM predb - WHERE filename = %s %s + WHERE filename = %s OR title = %1$s', - $this->pdo->escapeString($this->_fileName), - preg_match('/(\d{2}\.\d{2}\.\d{2})+[\w-.]+[\w]$/i', $this->_fileName, $match) ? 'OR filename ' . $this->pdo->likeString($match[0], true, false) : '' + $this->pdo->escapeString($this->_fileName) ) ); } diff --git a/resources/db/patches/mysql/+1~predb.sql b/resources/db/patches/mysql/+1~predb.sql deleted file mode 100644 index 966cf5dbd..000000000 --- a/resources/db/patches/mysql/+1~predb.sql +++ /dev/null @@ -1,3 +0,0 @@ -# Add FULLTEXT index on predb.filename. This patch might take some time to complete. - -ALTER TABLE predb ADD FULLTEXT INDEX ft_predb_filename (filename);