@@ -32,79 +32,79 @@ |
||
32 | 32 | use Sabre\DAV\IFile; |
33 | 33 | |
34 | 34 | class DirectFile implements IFile { |
35 | - /** @var Direct */ |
|
36 | - private $direct; |
|
35 | + /** @var Direct */ |
|
36 | + private $direct; |
|
37 | 37 | |
38 | - /** @var IRootFolder */ |
|
39 | - private $rootFolder; |
|
38 | + /** @var IRootFolder */ |
|
39 | + private $rootFolder; |
|
40 | 40 | |
41 | - /** @var File */ |
|
42 | - private $file; |
|
41 | + /** @var File */ |
|
42 | + private $file; |
|
43 | 43 | |
44 | - public function __construct(Direct $direct, IRootFolder $rootFolder) { |
|
45 | - $this->direct = $direct; |
|
46 | - $this->rootFolder = $rootFolder; |
|
47 | - } |
|
44 | + public function __construct(Direct $direct, IRootFolder $rootFolder) { |
|
45 | + $this->direct = $direct; |
|
46 | + $this->rootFolder = $rootFolder; |
|
47 | + } |
|
48 | 48 | |
49 | - public function put($data) { |
|
50 | - throw new Forbidden(); |
|
51 | - } |
|
49 | + public function put($data) { |
|
50 | + throw new Forbidden(); |
|
51 | + } |
|
52 | 52 | |
53 | - public function get() { |
|
54 | - $this->getFile(); |
|
53 | + public function get() { |
|
54 | + $this->getFile(); |
|
55 | 55 | |
56 | - return $this->file->fopen('rb'); |
|
57 | - } |
|
56 | + return $this->file->fopen('rb'); |
|
57 | + } |
|
58 | 58 | |
59 | - public function getContentType() { |
|
60 | - $this->getFile(); |
|
59 | + public function getContentType() { |
|
60 | + $this->getFile(); |
|
61 | 61 | |
62 | - return $this->file->getMimeType(); |
|
63 | - } |
|
62 | + return $this->file->getMimeType(); |
|
63 | + } |
|
64 | 64 | |
65 | - public function getETag() { |
|
66 | - $this->getFile(); |
|
65 | + public function getETag() { |
|
66 | + $this->getFile(); |
|
67 | 67 | |
68 | - return $this->file->getEtag(); |
|
69 | - } |
|
68 | + return $this->file->getEtag(); |
|
69 | + } |
|
70 | 70 | |
71 | - public function getSize() { |
|
72 | - $this->getFile(); |
|
71 | + public function getSize() { |
|
72 | + $this->getFile(); |
|
73 | 73 | |
74 | - return $this->file->getSize(); |
|
75 | - } |
|
74 | + return $this->file->getSize(); |
|
75 | + } |
|
76 | 76 | |
77 | - public function delete() { |
|
78 | - throw new Forbidden(); |
|
79 | - } |
|
77 | + public function delete() { |
|
78 | + throw new Forbidden(); |
|
79 | + } |
|
80 | 80 | |
81 | - public function getName() { |
|
82 | - return $this->direct->getToken(); |
|
83 | - } |
|
81 | + public function getName() { |
|
82 | + return $this->direct->getToken(); |
|
83 | + } |
|
84 | 84 | |
85 | - public function setName($name) { |
|
86 | - throw new Forbidden(); |
|
87 | - } |
|
85 | + public function setName($name) { |
|
86 | + throw new Forbidden(); |
|
87 | + } |
|
88 | 88 | |
89 | - public function getLastModified() { |
|
90 | - $this->getFile(); |
|
89 | + public function getLastModified() { |
|
90 | + $this->getFile(); |
|
91 | 91 | |
92 | - return $this->file->getMTime(); |
|
93 | - } |
|
92 | + return $this->file->getMTime(); |
|
93 | + } |
|
94 | 94 | |
95 | - private function getFile() { |
|
96 | - if ($this->file === null) { |
|
97 | - $userFolder = $this->rootFolder->getUserFolder($this->direct->getUserId()); |
|
98 | - $files = $userFolder->getById($this->direct->getFileId()); |
|
95 | + private function getFile() { |
|
96 | + if ($this->file === null) { |
|
97 | + $userFolder = $this->rootFolder->getUserFolder($this->direct->getUserId()); |
|
98 | + $files = $userFolder->getById($this->direct->getFileId()); |
|
99 | 99 | |
100 | - if ($files === []) { |
|
101 | - throw new NotFound(); |
|
102 | - } |
|
100 | + if ($files === []) { |
|
101 | + throw new NotFound(); |
|
102 | + } |
|
103 | 103 | |
104 | - $this->file = array_shift($files); |
|
105 | - } |
|
104 | + $this->file = array_shift($files); |
|
105 | + } |
|
106 | 106 | |
107 | - return $this->file; |
|
108 | - } |
|
107 | + return $this->file; |
|
108 | + } |
|
109 | 109 | |
110 | 110 | } |
@@ -29,14 +29,14 @@ |
||
29 | 29 | |
30 | 30 | class Errorlog implements IWriter { |
31 | 31 | |
32 | - /** |
|
33 | - * write a message in the log |
|
34 | - * @param string $app |
|
35 | - * @param string $message |
|
36 | - * @param int $level |
|
37 | - */ |
|
38 | - public function write(string $app, $message, int $level) { |
|
39 | - error_log('[owncloud]['.$app.']['.$level.'] '.$message); |
|
40 | - } |
|
32 | + /** |
|
33 | + * write a message in the log |
|
34 | + * @param string $app |
|
35 | + * @param string $message |
|
36 | + * @param int $level |
|
37 | + */ |
|
38 | + public function write(string $app, $message, int $level) { |
|
39 | + error_log('[owncloud]['.$app.']['.$level.'] '.$message); |
|
40 | + } |
|
41 | 41 | } |
42 | 42 |
@@ -30,8 +30,8 @@ |
||
30 | 30 | * @since 14.0.0 |
31 | 31 | */ |
32 | 32 | interface IWriter { |
33 | - /** |
|
34 | - * @since 14.0.0 |
|
35 | - */ |
|
36 | - public function write(string $app, $message, int $level); |
|
33 | + /** |
|
34 | + * @since 14.0.0 |
|
35 | + */ |
|
36 | + public function write(string $app, $message, int $level); |
|
37 | 37 | } |
@@ -32,40 +32,40 @@ |
||
32 | 32 | */ |
33 | 33 | trait RotationTrait { |
34 | 34 | |
35 | - /** |
|
36 | - * @var string |
|
37 | - * @since 14.0.0 |
|
38 | - */ |
|
39 | - protected $filePath; |
|
35 | + /** |
|
36 | + * @var string |
|
37 | + * @since 14.0.0 |
|
38 | + */ |
|
39 | + protected $filePath; |
|
40 | 40 | |
41 | - /** |
|
42 | - * @var int |
|
43 | - * @since 14.0.0 |
|
44 | - */ |
|
45 | - protected $maxSize; |
|
41 | + /** |
|
42 | + * @var int |
|
43 | + * @since 14.0.0 |
|
44 | + */ |
|
45 | + protected $maxSize; |
|
46 | 46 | |
47 | - /** |
|
48 | - * @return string the resulting new filepath |
|
49 | - * @since 14.0.0 |
|
50 | - */ |
|
51 | - protected function rotate():string { |
|
52 | - $rotatedFile = $this->filePath.'.1'; |
|
53 | - rename($this->filePath, $rotatedFile); |
|
54 | - return $rotatedFile; |
|
55 | - } |
|
47 | + /** |
|
48 | + * @return string the resulting new filepath |
|
49 | + * @since 14.0.0 |
|
50 | + */ |
|
51 | + protected function rotate():string { |
|
52 | + $rotatedFile = $this->filePath.'.1'; |
|
53 | + rename($this->filePath, $rotatedFile); |
|
54 | + return $rotatedFile; |
|
55 | + } |
|
56 | 56 | |
57 | - /** |
|
58 | - * @return bool |
|
59 | - * @since 14.0.0 |
|
60 | - */ |
|
61 | - protected function shouldRotateBySize():bool { |
|
62 | - if ((int)$this->maxSize > 0) { |
|
63 | - $filesize = @filesize($this->filePath); |
|
64 | - if ($filesize >= (int)$this->maxSize) { |
|
65 | - return true; |
|
66 | - } |
|
67 | - } |
|
68 | - return false; |
|
69 | - } |
|
57 | + /** |
|
58 | + * @return bool |
|
59 | + * @since 14.0.0 |
|
60 | + */ |
|
61 | + protected function shouldRotateBySize():bool { |
|
62 | + if ((int)$this->maxSize > 0) { |
|
63 | + $filesize = @filesize($this->filePath); |
|
64 | + if ($filesize >= (int)$this->maxSize) { |
|
65 | + return true; |
|
66 | + } |
|
67 | + } |
|
68 | + return false; |
|
69 | + } |
|
70 | 70 | |
71 | 71 | } |
@@ -37,82 +37,82 @@ |
||
37 | 37 | |
38 | 38 | class DirectHome implements ICollection { |
39 | 39 | |
40 | - /** @var IRootFolder */ |
|
41 | - private $rootFolder; |
|
42 | - |
|
43 | - /** @var DirectMapper */ |
|
44 | - private $mapper; |
|
45 | - |
|
46 | - /** @var ITimeFactory */ |
|
47 | - private $timeFactory; |
|
48 | - |
|
49 | - /** @var Throttler */ |
|
50 | - private $throttler; |
|
51 | - |
|
52 | - /** @var IRequest */ |
|
53 | - private $request; |
|
54 | - |
|
55 | - public function __construct(IRootFolder $rootFolder, |
|
56 | - DirectMapper $mapper, |
|
57 | - ITimeFactory $timeFactory, |
|
58 | - Throttler $throttler, |
|
59 | - IRequest $request) { |
|
60 | - $this->rootFolder = $rootFolder; |
|
61 | - $this->mapper = $mapper; |
|
62 | - $this->timeFactory = $timeFactory; |
|
63 | - $this->throttler = $throttler; |
|
64 | - $this->request = $request; |
|
65 | - } |
|
66 | - |
|
67 | - public function createFile($name, $data = null) { |
|
68 | - throw new Forbidden(); |
|
69 | - } |
|
70 | - |
|
71 | - public function createDirectory($name) { |
|
72 | - throw new Forbidden(); |
|
73 | - } |
|
74 | - |
|
75 | - public function getChild($name): DirectFile { |
|
76 | - try { |
|
77 | - $direct = $this->mapper->getByToken($name); |
|
78 | - |
|
79 | - // Expired |
|
80 | - if ($direct->getExpiration() < $this->timeFactory->getTime()) { |
|
81 | - throw new NotFound(); |
|
82 | - } |
|
83 | - |
|
84 | - return new DirectFile($direct, $this->rootFolder); |
|
85 | - } catch (DoesNotExistException $e) { |
|
86 | - // Since the token space is so huge only throttle on non exsisting token |
|
87 | - $this->throttler->registerAttempt('directlink', $this->request->getRemoteAddress()); |
|
88 | - $this->throttler->sleepDelay($this->request->getRemoteAddress(), 'directlink'); |
|
89 | - |
|
90 | - throw new NotFound(); |
|
91 | - } |
|
92 | - } |
|
93 | - |
|
94 | - public function getChildren() { |
|
95 | - throw new MethodNotAllowed('Listing members of this collection is disabled'); |
|
96 | - } |
|
97 | - |
|
98 | - public function childExists($name): bool { |
|
99 | - return false; |
|
100 | - } |
|
101 | - |
|
102 | - public function delete() { |
|
103 | - throw new Forbidden(); |
|
104 | - } |
|
105 | - |
|
106 | - public function getName(): string { |
|
107 | - return 'direct'; |
|
108 | - } |
|
109 | - |
|
110 | - public function setName($name) { |
|
111 | - throw new Forbidden(); |
|
112 | - } |
|
113 | - |
|
114 | - public function getLastModified(): int { |
|
115 | - return 0; |
|
116 | - } |
|
40 | + /** @var IRootFolder */ |
|
41 | + private $rootFolder; |
|
42 | + |
|
43 | + /** @var DirectMapper */ |
|
44 | + private $mapper; |
|
45 | + |
|
46 | + /** @var ITimeFactory */ |
|
47 | + private $timeFactory; |
|
48 | + |
|
49 | + /** @var Throttler */ |
|
50 | + private $throttler; |
|
51 | + |
|
52 | + /** @var IRequest */ |
|
53 | + private $request; |
|
54 | + |
|
55 | + public function __construct(IRootFolder $rootFolder, |
|
56 | + DirectMapper $mapper, |
|
57 | + ITimeFactory $timeFactory, |
|
58 | + Throttler $throttler, |
|
59 | + IRequest $request) { |
|
60 | + $this->rootFolder = $rootFolder; |
|
61 | + $this->mapper = $mapper; |
|
62 | + $this->timeFactory = $timeFactory; |
|
63 | + $this->throttler = $throttler; |
|
64 | + $this->request = $request; |
|
65 | + } |
|
66 | + |
|
67 | + public function createFile($name, $data = null) { |
|
68 | + throw new Forbidden(); |
|
69 | + } |
|
70 | + |
|
71 | + public function createDirectory($name) { |
|
72 | + throw new Forbidden(); |
|
73 | + } |
|
74 | + |
|
75 | + public function getChild($name): DirectFile { |
|
76 | + try { |
|
77 | + $direct = $this->mapper->getByToken($name); |
|
78 | + |
|
79 | + // Expired |
|
80 | + if ($direct->getExpiration() < $this->timeFactory->getTime()) { |
|
81 | + throw new NotFound(); |
|
82 | + } |
|
83 | + |
|
84 | + return new DirectFile($direct, $this->rootFolder); |
|
85 | + } catch (DoesNotExistException $e) { |
|
86 | + // Since the token space is so huge only throttle on non exsisting token |
|
87 | + $this->throttler->registerAttempt('directlink', $this->request->getRemoteAddress()); |
|
88 | + $this->throttler->sleepDelay($this->request->getRemoteAddress(), 'directlink'); |
|
89 | + |
|
90 | + throw new NotFound(); |
|
91 | + } |
|
92 | + } |
|
93 | + |
|
94 | + public function getChildren() { |
|
95 | + throw new MethodNotAllowed('Listing members of this collection is disabled'); |
|
96 | + } |
|
97 | + |
|
98 | + public function childExists($name): bool { |
|
99 | + return false; |
|
100 | + } |
|
101 | + |
|
102 | + public function delete() { |
|
103 | + throw new Forbidden(); |
|
104 | + } |
|
105 | + |
|
106 | + public function getName(): string { |
|
107 | + return 'direct'; |
|
108 | + } |
|
109 | + |
|
110 | + public function setName($name) { |
|
111 | + throw new Forbidden(); |
|
112 | + } |
|
113 | + |
|
114 | + public function getLastModified(): int { |
|
115 | + return 0; |
|
116 | + } |
|
117 | 117 | |
118 | 118 | } |
@@ -30,19 +30,19 @@ |
||
30 | 30 | |
31 | 31 | class AddPreviewBackgroundCleanupJob implements IRepairStep { |
32 | 32 | |
33 | - /** @var IJobList */ |
|
34 | - private $jobList; |
|
33 | + /** @var IJobList */ |
|
34 | + private $jobList; |
|
35 | 35 | |
36 | - public function __construct(IJobList $jobList) { |
|
37 | - $this->jobList = $jobList; |
|
38 | - } |
|
36 | + public function __construct(IJobList $jobList) { |
|
37 | + $this->jobList = $jobList; |
|
38 | + } |
|
39 | 39 | |
40 | - public function getName(): string { |
|
41 | - return 'Add preview background cleanup job'; |
|
42 | - } |
|
40 | + public function getName(): string { |
|
41 | + return 'Add preview background cleanup job'; |
|
42 | + } |
|
43 | 43 | |
44 | - public function run(IOutput $output) { |
|
45 | - $this->jobList->add(BackgroundCleanupJob::class); |
|
46 | - } |
|
44 | + public function run(IOutput $output) { |
|
45 | + $this->jobList->add(BackgroundCleanupJob::class); |
|
46 | + } |
|
47 | 47 | |
48 | 48 | } |
@@ -36,39 +36,39 @@ |
||
36 | 36 | * Class that will watch filesystem activity and remove previews as needed. |
37 | 37 | */ |
38 | 38 | class Watcher { |
39 | - /** @var IAppData */ |
|
40 | - private $appData; |
|
39 | + /** @var IAppData */ |
|
40 | + private $appData; |
|
41 | 41 | |
42 | - /** |
|
43 | - * Watcher constructor. |
|
44 | - * |
|
45 | - * @param IAppData $appData |
|
46 | - */ |
|
47 | - public function __construct(IAppData $appData) { |
|
48 | - $this->appData = $appData; |
|
49 | - } |
|
42 | + /** |
|
43 | + * Watcher constructor. |
|
44 | + * |
|
45 | + * @param IAppData $appData |
|
46 | + */ |
|
47 | + public function __construct(IAppData $appData) { |
|
48 | + $this->appData = $appData; |
|
49 | + } |
|
50 | 50 | |
51 | - public function postWrite(Node $node) { |
|
52 | - $this->deleteNode($node); |
|
53 | - } |
|
51 | + public function postWrite(Node $node) { |
|
52 | + $this->deleteNode($node); |
|
53 | + } |
|
54 | 54 | |
55 | - protected function deleteNode(Node $node) { |
|
56 | - // We only handle files |
|
57 | - if ($node instanceof Folder) { |
|
58 | - return; |
|
59 | - } |
|
55 | + protected function deleteNode(Node $node) { |
|
56 | + // We only handle files |
|
57 | + if ($node instanceof Folder) { |
|
58 | + return; |
|
59 | + } |
|
60 | 60 | |
61 | - try { |
|
62 | - $folder = $this->appData->getFolder((string)$node->getId()); |
|
63 | - $folder->delete(); |
|
64 | - } catch (NotFoundException $e) { |
|
65 | - //Nothing to do |
|
66 | - } |
|
67 | - } |
|
61 | + try { |
|
62 | + $folder = $this->appData->getFolder((string)$node->getId()); |
|
63 | + $folder->delete(); |
|
64 | + } catch (NotFoundException $e) { |
|
65 | + //Nothing to do |
|
66 | + } |
|
67 | + } |
|
68 | 68 | |
69 | - public function versionRollback(array $data) { |
|
70 | - if (isset($data['node'])) { |
|
71 | - $this->deleteNode($data['node']); |
|
72 | - } |
|
73 | - } |
|
69 | + public function versionRollback(array $data) { |
|
70 | + if (isset($data['node'])) { |
|
71 | + $this->deleteNode($data['node']); |
|
72 | + } |
|
73 | + } |
|
74 | 74 | } |
@@ -29,39 +29,39 @@ |
||
29 | 29 | |
30 | 30 | class WatcherConnector { |
31 | 31 | |
32 | - /** @var IRootFolder */ |
|
33 | - private $root; |
|
32 | + /** @var IRootFolder */ |
|
33 | + private $root; |
|
34 | 34 | |
35 | - /** @var SystemConfig */ |
|
36 | - private $config; |
|
35 | + /** @var SystemConfig */ |
|
36 | + private $config; |
|
37 | 37 | |
38 | - /** |
|
39 | - * WatcherConnector constructor. |
|
40 | - * |
|
41 | - * @param IRootFolder $root |
|
42 | - * @param SystemConfig $config |
|
43 | - */ |
|
44 | - public function __construct(IRootFolder $root, |
|
45 | - SystemConfig $config) { |
|
46 | - $this->root = $root; |
|
47 | - $this->config = $config; |
|
48 | - } |
|
38 | + /** |
|
39 | + * WatcherConnector constructor. |
|
40 | + * |
|
41 | + * @param IRootFolder $root |
|
42 | + * @param SystemConfig $config |
|
43 | + */ |
|
44 | + public function __construct(IRootFolder $root, |
|
45 | + SystemConfig $config) { |
|
46 | + $this->root = $root; |
|
47 | + $this->config = $config; |
|
48 | + } |
|
49 | 49 | |
50 | - /** |
|
51 | - * @return Watcher |
|
52 | - */ |
|
53 | - private function getWatcher(): Watcher { |
|
54 | - return \OC::$server->query(Watcher::class); |
|
55 | - } |
|
50 | + /** |
|
51 | + * @return Watcher |
|
52 | + */ |
|
53 | + private function getWatcher(): Watcher { |
|
54 | + return \OC::$server->query(Watcher::class); |
|
55 | + } |
|
56 | 56 | |
57 | - public function connectWatcher() { |
|
58 | - // Do not connect if we are not setup yet! |
|
59 | - if ($this->config->getValue('instanceid', null) !== null) { |
|
60 | - $this->root->listen('\OC\Files', 'postWrite', function (Node $node) { |
|
61 | - $this->getWatcher()->postWrite($node); |
|
62 | - }); |
|
57 | + public function connectWatcher() { |
|
58 | + // Do not connect if we are not setup yet! |
|
59 | + if ($this->config->getValue('instanceid', null) !== null) { |
|
60 | + $this->root->listen('\OC\Files', 'postWrite', function (Node $node) { |
|
61 | + $this->getWatcher()->postWrite($node); |
|
62 | + }); |
|
63 | 63 | |
64 | - \OC_Hook::connect('\OCP\Versions', 'rollback', $this->getWatcher(), 'versionRollback'); |
|
65 | - } |
|
66 | - } |
|
64 | + \OC_Hook::connect('\OCP\Versions', 'rollback', $this->getWatcher(), 'versionRollback'); |
|
65 | + } |
|
66 | + } |
|
67 | 67 | } |
@@ -29,8 +29,8 @@ |
||
29 | 29 | */ |
30 | 30 | interface ICountDisabledInGroup { |
31 | 31 | |
32 | - /** |
|
33 | - * @since 14.0.0 |
|
34 | - */ |
|
35 | - public function countDisabledInGroup(string $gid): int; |
|
32 | + /** |
|
33 | + * @since 14.0.0 |
|
34 | + */ |
|
35 | + public function countDisabledInGroup(string $gid): int; |
|
36 | 36 | } |