1
|
|
|
<?php |
2
|
|
|
/** |
3
|
|
|
* @copyright 2018, Roeland Jago Douma <[email protected]> |
4
|
|
|
* |
5
|
|
|
* @author Roeland Jago Douma <[email protected]> |
6
|
|
|
* |
7
|
|
|
* @license GNU AGPL version 3 or any later version |
8
|
|
|
* |
9
|
|
|
* This program is free software: you can redistribute it and/or modify |
10
|
|
|
* it under the terms of the GNU Affero General Public License as |
11
|
|
|
* published by the Free Software Foundation, either version 3 of the |
12
|
|
|
* License, or (at your option) any later version. |
13
|
|
|
* |
14
|
|
|
* This program is distributed in the hope that it will be useful, |
15
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of |
16
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
17
|
|
|
* GNU Affero General Public License for more details. |
18
|
|
|
* |
19
|
|
|
* You should have received a copy of the GNU Affero General Public License |
20
|
|
|
* along with this program. If not, see <http://www.gnu.org/licenses/>. |
21
|
|
|
* |
22
|
|
|
*/ |
23
|
|
|
|
24
|
|
|
namespace OCA\Files_Antivirus\Sabre; |
25
|
|
|
|
26
|
|
|
use OCA\DAV\Upload\FutureFile; |
27
|
|
|
use OCA\Files_Antivirus\AppConfig; |
28
|
|
|
use OCA\Files_Antivirus\Event\ScanStateEvent; |
29
|
|
|
use Sabre\DAV\Server; |
30
|
|
|
use Sabre\DAV\ServerPlugin; |
31
|
|
|
use Symfony\Component\EventDispatcher\EventDispatcherInterface; |
32
|
|
|
|
33
|
|
|
class PropfindPlugin extends ServerPlugin { |
34
|
|
|
|
35
|
|
|
/** @var Server */ |
36
|
|
|
private $server; |
37
|
|
|
|
38
|
|
|
/** @var AppConfig */ |
39
|
|
|
private $appConfig; |
40
|
|
|
|
41
|
|
|
/** @var EventDispatcherInterface */ |
42
|
|
|
private $eventDispatcher; |
43
|
|
|
|
44
|
|
|
|
45
|
|
|
public function __construct(AppConfig $appConfig, EventDispatcherInterface $eventDispatcher) { |
46
|
|
|
$this->appConfig = $appConfig; |
47
|
|
|
$this->eventDispatcher = $eventDispatcher; |
48
|
|
|
} |
49
|
|
|
|
50
|
|
|
public function initialize(Server $server) { |
51
|
|
|
$server->on('beforeMove', [$this, 'beforeMove'], 90); |
52
|
|
|
$this->server = $server; |
53
|
|
|
} |
54
|
|
|
|
55
|
|
|
/** |
56
|
|
|
* @param string $sourcePath source path |
57
|
|
|
* @param string $destination destination path |
58
|
|
|
*/ |
59
|
|
|
public function beforeMove($sourcePath, $destination) { |
60
|
|
|
$sourceNode = $this->server->tree->getNodeForPath($sourcePath); |
61
|
|
|
if (!$sourceNode instanceof FutureFile) { |
|
|
|
|
62
|
|
|
// skip handling as the source is not a chunked FutureFile |
63
|
|
|
return; |
64
|
|
|
} |
65
|
|
|
|
66
|
|
|
if ($sourceNode->getSize() > $this->appConfig->getAvMaxFileSize()) { |
67
|
|
|
$this->eventDispatcher->dispatch( |
68
|
|
|
ScanStateEvent::class, |
69
|
|
|
new ScanStateEvent(false) |
|
|
|
|
70
|
|
|
); |
71
|
|
|
} |
72
|
|
|
} |
73
|
|
|
} |
74
|
|
|
|
This error could be the result of:
1. Missing dependencies
PHP Analyzer uses your
composer.json
file (if available) to determine the dependencies of your project and to determine all the available classes and functions. It expects thecomposer.json
to be in the root folder of your repository.Are you sure this class is defined by one of your dependencies, or did you maybe not list a dependency in either the
require
orrequire-dev
section?2. Missing use statement
PHP does not complain about undefined classes in
ìnstanceof
checks. For example, the following PHP code will work perfectly fine:If you have not tested against this specific condition, such errors might go unnoticed.