diff options
author | Victor Dubiniuk <victor.dubiniuk@gmail.com> | 2016-11-11 19:10:42 +0300 |
---|---|---|
committer | Victor Dubiniuk <victor.dubiniuk@gmail.com> | 2016-11-11 19:10:42 +0300 |
commit | 7dff3342798b21ce9ac27ee7b04f148b1d0088bd (patch) | |
tree | a56a394a07295dbdd02ef8227d9f5e604a88618d | |
parent | 106c285c4c82d86f04d111f81b210ec6240f3643 (diff) |
Remove chunkSize from UI. Put shutdownScanner back
-rw-r--r-- | controller/settingscontroller.php | 4 | ||||
-rw-r--r-- | js/settings.js | 6 | ||||
-rw-r--r-- | lib/appconfig.php | 11 | ||||
-rw-r--r-- | lib/item.php | 4 | ||||
-rw-r--r-- | lib/scanner.php | 1 | ||||
-rw-r--r-- | templates/settings.php | 9 | ||||
-rw-r--r-- | tests/ItemTest.php | 6 | ||||
-rw-r--r-- | tests/TestBase.php | 2 |
8 files changed, 14 insertions, 29 deletions
diff --git a/controller/settingscontroller.php b/controller/settingscontroller.php index 6c10e2e..582098c 100644 --- a/controller/settingscontroller.php +++ b/controller/settingscontroller.php @@ -50,20 +50,18 @@ class SettingsController extends Controller { * @param string $avHost - antivirus url * @param int $avPort - port * @param string $avCmdOptions - extra command line options - * @param int $avChunkSize - Size of one portion * @param string $avPath - path to antivirus executable (Executable mode) * @param string $avInfectedAction - action performed on infected files * @param $avStreamMaxLength - reopen socket after bytes * @param int $avMaxFileSize - file size limit * @return JSONResponse */ - public function save($avMode, $avSocket, $avHost, $avPort, $avCmdOptions, $avChunkSize, $avPath, $avInfectedAction, $avStreamMaxLength, $avMaxFileSize) { + public function save($avMode, $avSocket, $avHost, $avPort, $avCmdOptions, $avPath, $avInfectedAction, $avStreamMaxLength, $avMaxFileSize) { $this->settings->setAvMode($avMode); $this->settings->setAvSocket($avSocket); $this->settings->setAvHost($avHost); $this->settings->setAvPort($avPort); $this->settings->setAvCmdOptions($avCmdOptions); - $this->settings->setAvChunkSize($avChunkSize); $this->settings->setAvPath($avPath); $this->settings->setAvInfectedAction($avInfectedAction); $this->settings->setAvStreamMaxLength($avStreamMaxLength); diff --git a/js/settings.js b/js/settings.js index a4604d9..b42f0cc 100644 --- a/js/settings.js +++ b/js/settings.js @@ -132,12 +132,12 @@ var antivirusSettings = antivirusSettings || { function av_mode_show_options(str){ if ( str == 'daemon'){ $('p.av_socket, p.av_path').hide('slow'); - $('p.av_host, p.av_port, p.av_stream_max_length').show('slow'); + $('p.av_host, p.av_port').show('slow'); } else if ( str == 'socket' ) { - $('p.av_socket, p.av_stream_max_length').show('slow'); + $('p.av_socket').show('slow'); $('p.av_path, p.av_host, p.av_port').hide('slow'); } else if (str == 'executable'){ - $('p.av_socket, p.av_host, p.av_port, p.av_stream_max_length').hide('slow'); + $('p.av_socket, p.av_host, p.av_port').hide('slow'); $('p.av_path').show('slow'); } } diff --git a/lib/appconfig.php b/lib/appconfig.php index 86e0df4..e355edd 100644 --- a/lib/appconfig.php +++ b/lib/appconfig.php @@ -18,10 +18,9 @@ use \OCP\IConfig; * @method int getAvMaxFileSize() * @method int getAvStreamMaxLength() * @method string getAvCmdOptions() - * @method int getAvChunkSize() * @method string getAvPath() * @method string getAvInfectedAction() - * + * * @method null setAvMode(string $avMode) * @method null setAvSocket(string $avsocket) * @method null setAvHost(string $avHost) @@ -29,7 +28,6 @@ use \OCP\IConfig; * @method null setAvMaxFileSize(int $fileSize) * @method null setAvStreamMaxLength(int $streamMaxLength) * @method null setAvCmdOptions(string $avCmdOptions) - * @method null setAvChunkSize(int $chunkSize) * @method null setAvPath(string $avPath) * @method null setAvInfectedAction(string $avInfectedAction) */ @@ -46,7 +44,6 @@ class AppConfig { 'av_host' => '', 'av_port' => '', 'av_cmd_options' => '', - 'av_chunk_size' => '8192', 'av_path' => '/usr/bin/clamscan', 'av_max_file_size' => -1, 'av_stream_max_length' => '26214400', @@ -61,6 +58,12 @@ class AppConfig { public function __construct(IConfig $config) { $this->config = $config; } + + public function getAvChunkSize(){ + // See http://php.net/manual/en/function.stream-wrapper-register.php#74765 + // and \OC_Helper::streamCopy + return 8192; + } /** * Get full commandline diff --git a/lib/item.php b/lib/item.php index b2f4ac3..ea74dcd 100644 --- a/lib/item.php +++ b/lib/item.php @@ -78,7 +78,7 @@ class Item implements IScannable{ $this->isValidSize = $view->filesize($path) > 0; - $application = new \OCA\Files_Antivirus\AppInfo\Application(); + $application = new AppInfo\Application(); $config = $application->getContainer()->query('AppConfig'); $this->chunkSize = $config->getAvChunkSize(); } @@ -117,7 +117,7 @@ class Item implements IScannable{ * @param boolean $isBackground */ public function processInfected(Status $status, $isBackground) { - $application = new \OCA\Files_Antivirus\AppInfo\Application(); + $application = new AppInfo\Application(); $appConfig = $application->getContainer()->query('AppConfig'); $infectedAction = $appConfig->getAvInfectedAction(); diff --git a/lib/scanner.php b/lib/scanner.php index cda2b7d..6984249 100644 --- a/lib/scanner.php +++ b/lib/scanner.php @@ -140,6 +140,7 @@ abstract class Scanner { 'reinit scanner', ['app' => 'files_antivirus'] ); + $this->shutdownScanner(); $isReopenSuccessful = $this->retry(); } else { $isReopenSuccessful = true; diff --git a/templates/settings.php b/templates/settings.php index 0e51d91..56c8893 100644 --- a/templates/settings.php +++ b/templates/settings.php @@ -12,15 +12,6 @@ script('files_antivirus', 'settings'); <p class="av_socket"><label for="av_socket"><?php p($l->t('Socket'));?></label><input type="text" id="av_socket" name="avSocket" value="<?php p($_['avSocket']); ?>" title="<?php p($l->t('Clamav Socket.')).' '.$l->t('Not required in Executable Mode.'); ?>"></p> <p class="av_host"><label for="av_host"><?php p($l->t('Host'));?></label><input type="text" id="av_host" name="avHost" value="<?php p($_['avHost']); ?>" title="<?php p($l->t('Address of Antivirus Host.')). ' ' .$l->t('Not required in Executable Mode.');?>"></p> <p class="av_port"><label for="av_port"><?php p($l->t('Port'));?></label><input type="text" id="av_port" name="avPort" value="<?php p($_['avPort']); ?>" title="<?php p($l->t('Port number of Antivirus Host.')). ' ' .$l->t('Not required in Executable Mode.');?>"></p> - <p class="av_chunk_size"> - <label for="av_chunk_size"> - <?php p($l->t('Chunk Size'));?> - </label> - <input type="text" id="av_chunk_size" name="avChunkSize" value="<?php p($_['avChunkSize']); ?>" - title="<?php p($l->t('Chunk size')). ' ' .$l->t('Not required in Executable Mode.');?>" - /> - <label for="av_chunk_size" class="a-left"><?php p($l->t('bytes'))?></label> - </p> <p class="av_stream_max_length"> <label for="av_stream_max_length"> <?php p($l->t('Stream Length'));?> diff --git a/tests/ItemTest.php b/tests/ItemTest.php index 8c472ed..fd704fe 100644 --- a/tests/ItemTest.php +++ b/tests/ItemTest.php @@ -41,12 +41,6 @@ class ItemTest extends TestBase { \OC\Files\Filesystem::init('test', ''); $view = new \OC\Files\View('/test/files'); $view->file_put_contents('file1', self::CONTENT); - $this->config->method('__call') - ->with( - $this->equalTo('getAvChunkSize') - ) - ->willReturn('1024') - ; } public function testRead() { diff --git a/tests/TestBase.php b/tests/TestBase.php index ee80e5f..15637b5 100644 --- a/tests/TestBase.php +++ b/tests/TestBase.php @@ -47,8 +47,6 @@ abstract class TestBase extends \PHPUnit_Framework_TestCase { switch ($methodName){ case 'getAvPath': return __DIR__ . '/avir.sh'; - case 'getAvChunkSize': - return 1024; case 'getAvMode': return 'executable'; } |