@@ -34,7 +34,7 @@ |
||
34 | 34 | * @package OC\AppFramework\Middleware\Security\Exceptions |
35 | 35 | */ |
36 | 36 | class CrossSiteRequestForgeryException extends SecurityException { |
37 | - public function __construct() { |
|
38 | - parent::__construct('CSRF check failed', Http::STATUS_PRECONDITION_FAILED); |
|
39 | - } |
|
37 | + public function __construct() { |
|
38 | + parent::__construct('CSRF check failed', Http::STATUS_PRECONDITION_FAILED); |
|
39 | + } |
|
40 | 40 | } |
@@ -34,7 +34,7 @@ |
||
34 | 34 | * @package OC\AppFramework\Middleware\Security\Exceptions |
35 | 35 | */ |
36 | 36 | class AppNotEnabledException extends SecurityException { |
37 | - public function __construct() { |
|
38 | - parent::__construct('App is not enabled', Http::STATUS_PRECONDITION_FAILED); |
|
39 | - } |
|
37 | + public function __construct() { |
|
38 | + parent::__construct('App is not enabled', Http::STATUS_PRECONDITION_FAILED); |
|
39 | + } |
|
40 | 40 | } |
@@ -34,7 +34,7 @@ |
||
34 | 34 | * @package OC\AppFramework\Middleware\Security\Exceptions |
35 | 35 | */ |
36 | 36 | class NotLoggedInException extends SecurityException { |
37 | - public function __construct() { |
|
38 | - parent::__construct('Current user is not logged in', Http::STATUS_UNAUTHORIZED); |
|
39 | - } |
|
37 | + public function __construct() { |
|
38 | + parent::__construct('Current user is not logged in', Http::STATUS_UNAUTHORIZED); |
|
39 | + } |
|
40 | 40 | } |
@@ -27,50 +27,50 @@ |
||
27 | 27 | |
28 | 28 | class V2Response extends BaseResponse { |
29 | 29 | |
30 | - /** |
|
31 | - * The V2 endpoint just passes on status codes. |
|
32 | - * Of course we have to map the OCS specific codes to proper HTTP status codes |
|
33 | - * |
|
34 | - * @return int |
|
35 | - */ |
|
36 | - public function getStatus() { |
|
30 | + /** |
|
31 | + * The V2 endpoint just passes on status codes. |
|
32 | + * Of course we have to map the OCS specific codes to proper HTTP status codes |
|
33 | + * |
|
34 | + * @return int |
|
35 | + */ |
|
36 | + public function getStatus() { |
|
37 | 37 | |
38 | - $status = parent::getStatus(); |
|
39 | - if ($status === API::RESPOND_UNAUTHORISED) { |
|
40 | - return Http::STATUS_UNAUTHORIZED; |
|
41 | - } else if ($status === API::RESPOND_NOT_FOUND) { |
|
42 | - return Http::STATUS_NOT_FOUND; |
|
43 | - } else if ($status === API::RESPOND_SERVER_ERROR || $status === API::RESPOND_UNKNOWN_ERROR) { |
|
44 | - return Http::STATUS_INTERNAL_SERVER_ERROR; |
|
45 | - } else if ($status < 200 || $status > 600) { |
|
46 | - return Http::STATUS_BAD_REQUEST; |
|
47 | - } |
|
38 | + $status = parent::getStatus(); |
|
39 | + if ($status === API::RESPOND_UNAUTHORISED) { |
|
40 | + return Http::STATUS_UNAUTHORIZED; |
|
41 | + } else if ($status === API::RESPOND_NOT_FOUND) { |
|
42 | + return Http::STATUS_NOT_FOUND; |
|
43 | + } else if ($status === API::RESPOND_SERVER_ERROR || $status === API::RESPOND_UNKNOWN_ERROR) { |
|
44 | + return Http::STATUS_INTERNAL_SERVER_ERROR; |
|
45 | + } else if ($status < 200 || $status > 600) { |
|
46 | + return Http::STATUS_BAD_REQUEST; |
|
47 | + } |
|
48 | 48 | |
49 | - return $status; |
|
50 | - } |
|
49 | + return $status; |
|
50 | + } |
|
51 | 51 | |
52 | - /** |
|
53 | - * Construct the meta part of the response |
|
54 | - * And then late the base class render |
|
55 | - * |
|
56 | - * @return string |
|
57 | - */ |
|
58 | - public function render() { |
|
59 | - $status = parent::getStatus(); |
|
52 | + /** |
|
53 | + * Construct the meta part of the response |
|
54 | + * And then late the base class render |
|
55 | + * |
|
56 | + * @return string |
|
57 | + */ |
|
58 | + public function render() { |
|
59 | + $status = parent::getStatus(); |
|
60 | 60 | |
61 | - $meta = [ |
|
62 | - 'status' => $status >= 200 && $status < 300 ? 'ok' : 'failure', |
|
63 | - 'statuscode' => $this->getOCSStatus(), |
|
64 | - 'message' => $status >= 200 && $status < 300 ? 'OK' : $this->statusMessage, |
|
65 | - ]; |
|
61 | + $meta = [ |
|
62 | + 'status' => $status >= 200 && $status < 300 ? 'ok' : 'failure', |
|
63 | + 'statuscode' => $this->getOCSStatus(), |
|
64 | + 'message' => $status >= 200 && $status < 300 ? 'OK' : $this->statusMessage, |
|
65 | + ]; |
|
66 | 66 | |
67 | - if ($this->itemsCount !== null) { |
|
68 | - $meta['totalitems'] = $this->itemsCount; |
|
69 | - } |
|
70 | - if ($this->itemsPerPage !== null) { |
|
71 | - $meta['itemsperpage'] = $this->itemsPerPage; |
|
72 | - } |
|
67 | + if ($this->itemsCount !== null) { |
|
68 | + $meta['totalitems'] = $this->itemsCount; |
|
69 | + } |
|
70 | + if ($this->itemsPerPage !== null) { |
|
71 | + $meta['itemsperpage'] = $this->itemsPerPage; |
|
72 | + } |
|
73 | 73 | |
74 | - return $this->renderResult($meta); |
|
75 | - } |
|
74 | + return $this->renderResult($meta); |
|
75 | + } |
|
76 | 76 | } |
@@ -27,52 +27,52 @@ |
||
27 | 27 | |
28 | 28 | class V1Response extends BaseResponse { |
29 | 29 | |
30 | - /** |
|
31 | - * The V1 endpoint has very limited http status codes basically everything |
|
32 | - * is status 200 except 401 |
|
33 | - * |
|
34 | - * @return int |
|
35 | - */ |
|
36 | - public function getStatus() { |
|
37 | - $status = parent::getStatus(); |
|
38 | - if ($status === Http::STATUS_FORBIDDEN || $status === API::RESPOND_UNAUTHORISED) { |
|
39 | - return Http::STATUS_UNAUTHORIZED; |
|
40 | - } |
|
30 | + /** |
|
31 | + * The V1 endpoint has very limited http status codes basically everything |
|
32 | + * is status 200 except 401 |
|
33 | + * |
|
34 | + * @return int |
|
35 | + */ |
|
36 | + public function getStatus() { |
|
37 | + $status = parent::getStatus(); |
|
38 | + if ($status === Http::STATUS_FORBIDDEN || $status === API::RESPOND_UNAUTHORISED) { |
|
39 | + return Http::STATUS_UNAUTHORIZED; |
|
40 | + } |
|
41 | 41 | |
42 | - return Http::STATUS_OK; |
|
43 | - } |
|
42 | + return Http::STATUS_OK; |
|
43 | + } |
|
44 | 44 | |
45 | - /** |
|
46 | - * In v1 all OK is 100 |
|
47 | - * |
|
48 | - * @return int |
|
49 | - */ |
|
50 | - public function getOCSStatus() { |
|
51 | - $status = parent::getOCSStatus(); |
|
45 | + /** |
|
46 | + * In v1 all OK is 100 |
|
47 | + * |
|
48 | + * @return int |
|
49 | + */ |
|
50 | + public function getOCSStatus() { |
|
51 | + $status = parent::getOCSStatus(); |
|
52 | 52 | |
53 | - if ($status === Http::STATUS_OK) { |
|
54 | - return 100; |
|
55 | - } |
|
53 | + if ($status === Http::STATUS_OK) { |
|
54 | + return 100; |
|
55 | + } |
|
56 | 56 | |
57 | - return $status; |
|
58 | - } |
|
57 | + return $status; |
|
58 | + } |
|
59 | 59 | |
60 | - /** |
|
61 | - * Construct the meta part of the response |
|
62 | - * And then late the base class render |
|
63 | - * |
|
64 | - * @return string |
|
65 | - */ |
|
66 | - public function render() { |
|
67 | - $meta = [ |
|
68 | - 'status' => $this->getOCSStatus() === 100 ? 'ok' : 'failure', |
|
69 | - 'statuscode' => $this->getOCSStatus(), |
|
70 | - 'message' => $this->getOCSStatus() === 100 ? 'OK' : $this->statusMessage, |
|
71 | - ]; |
|
60 | + /** |
|
61 | + * Construct the meta part of the response |
|
62 | + * And then late the base class render |
|
63 | + * |
|
64 | + * @return string |
|
65 | + */ |
|
66 | + public function render() { |
|
67 | + $meta = [ |
|
68 | + 'status' => $this->getOCSStatus() === 100 ? 'ok' : 'failure', |
|
69 | + 'statuscode' => $this->getOCSStatus(), |
|
70 | + 'message' => $this->getOCSStatus() === 100 ? 'OK' : $this->statusMessage, |
|
71 | + ]; |
|
72 | 72 | |
73 | - $meta['totalitems'] = $this->itemsCount !== null ? (string)$this->itemsCount : ''; |
|
74 | - $meta['itemsperpage'] = $this->itemsPerPage !== null ? (string)$this->itemsPerPage: ''; |
|
73 | + $meta['totalitems'] = $this->itemsCount !== null ? (string)$this->itemsCount : ''; |
|
74 | + $meta['itemsperpage'] = $this->itemsPerPage !== null ? (string)$this->itemsPerPage: ''; |
|
75 | 75 | |
76 | - return $this->renderResult($meta); |
|
77 | - } |
|
76 | + return $this->renderResult($meta); |
|
77 | + } |
|
78 | 78 | } |
@@ -29,21 +29,21 @@ |
||
29 | 29 | use \OC\AppFramework\DependencyInjection\DIContainer; |
30 | 30 | |
31 | 31 | class RouteActionHandler { |
32 | - private $controllerName; |
|
33 | - private $actionName; |
|
34 | - private $container; |
|
32 | + private $controllerName; |
|
33 | + private $actionName; |
|
34 | + private $container; |
|
35 | 35 | |
36 | - /** |
|
37 | - * @param string $controllerName |
|
38 | - * @param string $actionName |
|
39 | - */ |
|
40 | - public function __construct(DIContainer $container, $controllerName, $actionName) { |
|
41 | - $this->controllerName = $controllerName; |
|
42 | - $this->actionName = $actionName; |
|
43 | - $this->container = $container; |
|
44 | - } |
|
36 | + /** |
|
37 | + * @param string $controllerName |
|
38 | + * @param string $actionName |
|
39 | + */ |
|
40 | + public function __construct(DIContainer $container, $controllerName, $actionName) { |
|
41 | + $this->controllerName = $controllerName; |
|
42 | + $this->actionName = $actionName; |
|
43 | + $this->container = $container; |
|
44 | + } |
|
45 | 45 | |
46 | - public function __invoke($params) { |
|
47 | - App::main($this->controllerName, $this->actionName, $this->container, $params); |
|
48 | - } |
|
46 | + public function __invoke($params) { |
|
47 | + App::main($this->controllerName, $this->actionName, $this->container, $params); |
|
48 | + } |
|
49 | 49 | } |
@@ -26,51 +26,51 @@ |
||
26 | 26 | use OCP\ILogger; |
27 | 27 | |
28 | 28 | class SearchResultSorter { |
29 | - private $search; |
|
30 | - private $encoding; |
|
31 | - private $key; |
|
32 | - private $log; |
|
29 | + private $search; |
|
30 | + private $encoding; |
|
31 | + private $key; |
|
32 | + private $log; |
|
33 | 33 | |
34 | - /** |
|
35 | - * @param string $search the search term as was given by the user |
|
36 | - * @param string $key the array key containing the value that should be compared |
|
37 | - * against |
|
38 | - * @param string $encoding optional, encoding to use, defaults to UTF-8 |
|
39 | - * @param ILogger $log optional |
|
40 | - */ |
|
41 | - public function __construct($search, $key, ILogger $log = null, $encoding = 'UTF-8') { |
|
42 | - $this->encoding = $encoding; |
|
43 | - $this->key = $key; |
|
44 | - $this->log = $log; |
|
45 | - $this->search = mb_strtolower($search, $this->encoding); |
|
46 | - } |
|
34 | + /** |
|
35 | + * @param string $search the search term as was given by the user |
|
36 | + * @param string $key the array key containing the value that should be compared |
|
37 | + * against |
|
38 | + * @param string $encoding optional, encoding to use, defaults to UTF-8 |
|
39 | + * @param ILogger $log optional |
|
40 | + */ |
|
41 | + public function __construct($search, $key, ILogger $log = null, $encoding = 'UTF-8') { |
|
42 | + $this->encoding = $encoding; |
|
43 | + $this->key = $key; |
|
44 | + $this->log = $log; |
|
45 | + $this->search = mb_strtolower($search, $this->encoding); |
|
46 | + } |
|
47 | 47 | |
48 | - /** |
|
49 | - * User and Group names matching the search term at the beginning shall appear |
|
50 | - * on top of the share dialog. Following entries in alphabetical order. |
|
51 | - * Callback function for usort. http://php.net/usort |
|
52 | - */ |
|
53 | - public function sort($a, $b) { |
|
54 | - if(!isset($a[$this->key]) || !isset($b[$this->key])) { |
|
55 | - if(!is_null($this->log)) { |
|
56 | - $this->log->error('Sharing dialogue: cannot sort due to ' . |
|
57 | - 'missing array key', array('app' => 'core')); |
|
58 | - } |
|
59 | - return 0; |
|
60 | - } |
|
61 | - $nameA = mb_strtolower($a[$this->key], $this->encoding); |
|
62 | - $nameB = mb_strtolower($b[$this->key], $this->encoding); |
|
63 | - $i = mb_strpos($nameA, $this->search, 0, $this->encoding); |
|
64 | - $j = mb_strpos($nameB, $this->search, 0, $this->encoding); |
|
48 | + /** |
|
49 | + * User and Group names matching the search term at the beginning shall appear |
|
50 | + * on top of the share dialog. Following entries in alphabetical order. |
|
51 | + * Callback function for usort. http://php.net/usort |
|
52 | + */ |
|
53 | + public function sort($a, $b) { |
|
54 | + if(!isset($a[$this->key]) || !isset($b[$this->key])) { |
|
55 | + if(!is_null($this->log)) { |
|
56 | + $this->log->error('Sharing dialogue: cannot sort due to ' . |
|
57 | + 'missing array key', array('app' => 'core')); |
|
58 | + } |
|
59 | + return 0; |
|
60 | + } |
|
61 | + $nameA = mb_strtolower($a[$this->key], $this->encoding); |
|
62 | + $nameB = mb_strtolower($b[$this->key], $this->encoding); |
|
63 | + $i = mb_strpos($nameA, $this->search, 0, $this->encoding); |
|
64 | + $j = mb_strpos($nameB, $this->search, 0, $this->encoding); |
|
65 | 65 | |
66 | - if($i === $j || $i > 0 && $j > 0) { |
|
67 | - return strcmp(mb_strtolower($nameA, $this->encoding), |
|
68 | - mb_strtolower($nameB, $this->encoding)); |
|
69 | - } elseif ($i === 0) { |
|
70 | - return -1; |
|
71 | - } else { |
|
72 | - return 1; |
|
73 | - } |
|
74 | - } |
|
66 | + if($i === $j || $i > 0 && $j > 0) { |
|
67 | + return strcmp(mb_strtolower($nameA, $this->encoding), |
|
68 | + mb_strtolower($nameB, $this->encoding)); |
|
69 | + } elseif ($i === 0) { |
|
70 | + return -1; |
|
71 | + } else { |
|
72 | + return 1; |
|
73 | + } |
|
74 | + } |
|
75 | 75 | } |
76 | 76 |
@@ -35,107 +35,107 @@ |
||
35 | 35 | */ |
36 | 36 | class RemoveRootShares implements IRepairStep { |
37 | 37 | |
38 | - /** @var IDBConnection */ |
|
39 | - protected $connection; |
|
40 | - |
|
41 | - /** @var IUserManager */ |
|
42 | - protected $userManager; |
|
43 | - |
|
44 | - /** @var IRootFolder */ |
|
45 | - protected $rootFolder; |
|
46 | - |
|
47 | - /** |
|
48 | - * RemoveRootShares constructor. |
|
49 | - * |
|
50 | - * @param IDBConnection $connection |
|
51 | - * @param IUserManager $userManager |
|
52 | - * @param IRootFolder $rootFolder |
|
53 | - */ |
|
54 | - public function __construct(IDBConnection $connection, |
|
55 | - IUserManager $userManager, |
|
56 | - IRootFolder $rootFolder) { |
|
57 | - $this->connection = $connection; |
|
58 | - $this->userManager = $userManager; |
|
59 | - $this->rootFolder = $rootFolder; |
|
60 | - } |
|
61 | - |
|
62 | - /** |
|
63 | - * @return string |
|
64 | - */ |
|
65 | - public function getName() { |
|
66 | - return 'Remove shares of a users root folder'; |
|
67 | - } |
|
68 | - |
|
69 | - /** |
|
70 | - * @param IOutput $output |
|
71 | - */ |
|
72 | - public function run(IOutput $output) { |
|
73 | - if ($this->rootSharesExist()) { |
|
74 | - $this->removeRootShares($output); |
|
75 | - } |
|
76 | - } |
|
77 | - |
|
78 | - /** |
|
79 | - * @param IOutput $output |
|
80 | - */ |
|
81 | - private function removeRootShares(IOutput $output) { |
|
82 | - $function = function(IUser $user) use ($output) { |
|
83 | - $userFolder = $this->rootFolder->getUserFolder($user->getUID()); |
|
84 | - $fileId = $userFolder->getId(); |
|
85 | - |
|
86 | - $qb = $this->connection->getQueryBuilder(); |
|
87 | - $qb->delete('share') |
|
88 | - ->where($qb->expr()->eq('file_source', $qb->createNamedParameter($fileId))) |
|
89 | - ->andWhere($qb->expr()->orX( |
|
90 | - $qb->expr()->eq('item_type', $qb->expr()->literal('file')), |
|
91 | - $qb->expr()->eq('item_type', $qb->expr()->literal('folder')) |
|
92 | - )); |
|
93 | - |
|
94 | - $qb->execute(); |
|
95 | - |
|
96 | - $output->advance(); |
|
97 | - }; |
|
98 | - |
|
99 | - $output->startProgress($this->userManager->countSeenUsers()); |
|
100 | - |
|
101 | - $this->userManager->callForSeenUsers($function); |
|
102 | - |
|
103 | - $output->finishProgress(); |
|
104 | - } |
|
105 | - |
|
106 | - /** |
|
107 | - * Verify if this repair steps is required |
|
108 | - * It *should* not be necessary in most cases and it can be very |
|
109 | - * costly. |
|
110 | - * |
|
111 | - * @return bool |
|
112 | - */ |
|
113 | - private function rootSharesExist() { |
|
114 | - $qb = $this->connection->getQueryBuilder(); |
|
115 | - $qb2 = $this->connection->getQueryBuilder(); |
|
116 | - |
|
117 | - $qb->select('fileid') |
|
118 | - ->from('filecache') |
|
119 | - ->where($qb->expr()->eq('path', $qb->expr()->literal('files'))); |
|
120 | - |
|
121 | - $qb2->select('id') |
|
122 | - ->from('share') |
|
123 | - ->where($qb2->expr()->in('file_source', $qb2->createFunction($qb->getSQL()))) |
|
124 | - ->andWhere($qb2->expr()->orX( |
|
125 | - $qb2->expr()->eq('item_type', $qb->expr()->literal('file')), |
|
126 | - $qb2->expr()->eq('item_type', $qb->expr()->literal('folder')) |
|
127 | - )) |
|
128 | - ->setMaxResults(1); |
|
129 | - |
|
130 | - $cursor = $qb2->execute(); |
|
131 | - $data = $cursor->fetch(); |
|
132 | - $cursor->closeCursor(); |
|
133 | - |
|
134 | - if ($data === false) { |
|
135 | - return false; |
|
136 | - } |
|
137 | - |
|
138 | - return true; |
|
139 | - } |
|
38 | + /** @var IDBConnection */ |
|
39 | + protected $connection; |
|
40 | + |
|
41 | + /** @var IUserManager */ |
|
42 | + protected $userManager; |
|
43 | + |
|
44 | + /** @var IRootFolder */ |
|
45 | + protected $rootFolder; |
|
46 | + |
|
47 | + /** |
|
48 | + * RemoveRootShares constructor. |
|
49 | + * |
|
50 | + * @param IDBConnection $connection |
|
51 | + * @param IUserManager $userManager |
|
52 | + * @param IRootFolder $rootFolder |
|
53 | + */ |
|
54 | + public function __construct(IDBConnection $connection, |
|
55 | + IUserManager $userManager, |
|
56 | + IRootFolder $rootFolder) { |
|
57 | + $this->connection = $connection; |
|
58 | + $this->userManager = $userManager; |
|
59 | + $this->rootFolder = $rootFolder; |
|
60 | + } |
|
61 | + |
|
62 | + /** |
|
63 | + * @return string |
|
64 | + */ |
|
65 | + public function getName() { |
|
66 | + return 'Remove shares of a users root folder'; |
|
67 | + } |
|
68 | + |
|
69 | + /** |
|
70 | + * @param IOutput $output |
|
71 | + */ |
|
72 | + public function run(IOutput $output) { |
|
73 | + if ($this->rootSharesExist()) { |
|
74 | + $this->removeRootShares($output); |
|
75 | + } |
|
76 | + } |
|
77 | + |
|
78 | + /** |
|
79 | + * @param IOutput $output |
|
80 | + */ |
|
81 | + private function removeRootShares(IOutput $output) { |
|
82 | + $function = function(IUser $user) use ($output) { |
|
83 | + $userFolder = $this->rootFolder->getUserFolder($user->getUID()); |
|
84 | + $fileId = $userFolder->getId(); |
|
85 | + |
|
86 | + $qb = $this->connection->getQueryBuilder(); |
|
87 | + $qb->delete('share') |
|
88 | + ->where($qb->expr()->eq('file_source', $qb->createNamedParameter($fileId))) |
|
89 | + ->andWhere($qb->expr()->orX( |
|
90 | + $qb->expr()->eq('item_type', $qb->expr()->literal('file')), |
|
91 | + $qb->expr()->eq('item_type', $qb->expr()->literal('folder')) |
|
92 | + )); |
|
93 | + |
|
94 | + $qb->execute(); |
|
95 | + |
|
96 | + $output->advance(); |
|
97 | + }; |
|
98 | + |
|
99 | + $output->startProgress($this->userManager->countSeenUsers()); |
|
100 | + |
|
101 | + $this->userManager->callForSeenUsers($function); |
|
102 | + |
|
103 | + $output->finishProgress(); |
|
104 | + } |
|
105 | + |
|
106 | + /** |
|
107 | + * Verify if this repair steps is required |
|
108 | + * It *should* not be necessary in most cases and it can be very |
|
109 | + * costly. |
|
110 | + * |
|
111 | + * @return bool |
|
112 | + */ |
|
113 | + private function rootSharesExist() { |
|
114 | + $qb = $this->connection->getQueryBuilder(); |
|
115 | + $qb2 = $this->connection->getQueryBuilder(); |
|
116 | + |
|
117 | + $qb->select('fileid') |
|
118 | + ->from('filecache') |
|
119 | + ->where($qb->expr()->eq('path', $qb->expr()->literal('files'))); |
|
120 | + |
|
121 | + $qb2->select('id') |
|
122 | + ->from('share') |
|
123 | + ->where($qb2->expr()->in('file_source', $qb2->createFunction($qb->getSQL()))) |
|
124 | + ->andWhere($qb2->expr()->orX( |
|
125 | + $qb2->expr()->eq('item_type', $qb->expr()->literal('file')), |
|
126 | + $qb2->expr()->eq('item_type', $qb->expr()->literal('folder')) |
|
127 | + )) |
|
128 | + ->setMaxResults(1); |
|
129 | + |
|
130 | + $cursor = $qb2->execute(); |
|
131 | + $data = $cursor->fetch(); |
|
132 | + $cursor->closeCursor(); |
|
133 | + |
|
134 | + if ($data === false) { |
|
135 | + return false; |
|
136 | + } |
|
137 | + |
|
138 | + return true; |
|
139 | + } |
|
140 | 140 | } |
141 | 141 |
@@ -28,53 +28,53 @@ |
||
28 | 28 | |
29 | 29 | class MoveUpdaterStepFile implements IRepairStep { |
30 | 30 | |
31 | - /** @var \OCP\IConfig */ |
|
32 | - protected $config; |
|
31 | + /** @var \OCP\IConfig */ |
|
32 | + protected $config; |
|
33 | 33 | |
34 | - /** |
|
35 | - * @param \OCP\IConfig $config |
|
36 | - */ |
|
37 | - public function __construct($config) { |
|
38 | - $this->config = $config; |
|
39 | - } |
|
34 | + /** |
|
35 | + * @param \OCP\IConfig $config |
|
36 | + */ |
|
37 | + public function __construct($config) { |
|
38 | + $this->config = $config; |
|
39 | + } |
|
40 | 40 | |
41 | - public function getName() { |
|
42 | - return 'Move .step file of updater to backup location'; |
|
43 | - } |
|
41 | + public function getName() { |
|
42 | + return 'Move .step file of updater to backup location'; |
|
43 | + } |
|
44 | 44 | |
45 | - public function run(IOutput $output) { |
|
45 | + public function run(IOutput $output) { |
|
46 | 46 | |
47 | - $dataDir = $this->config->getSystemValue('datadirectory', \OC::$SERVERROOT . '/data'); |
|
48 | - $instanceId = $this->config->getSystemValue('instanceid', null); |
|
47 | + $dataDir = $this->config->getSystemValue('datadirectory', \OC::$SERVERROOT . '/data'); |
|
48 | + $instanceId = $this->config->getSystemValue('instanceid', null); |
|
49 | 49 | |
50 | - if(!is_string($instanceId) || empty($instanceId)) { |
|
51 | - return; |
|
52 | - } |
|
50 | + if(!is_string($instanceId) || empty($instanceId)) { |
|
51 | + return; |
|
52 | + } |
|
53 | 53 | |
54 | - $updaterFolderPath = $dataDir . '/updater-' . $instanceId; |
|
55 | - $stepFile = $updaterFolderPath . '/.step'; |
|
56 | - if(file_exists($stepFile)) { |
|
57 | - $output->info('.step file exists'); |
|
54 | + $updaterFolderPath = $dataDir . '/updater-' . $instanceId; |
|
55 | + $stepFile = $updaterFolderPath . '/.step'; |
|
56 | + if(file_exists($stepFile)) { |
|
57 | + $output->info('.step file exists'); |
|
58 | 58 | |
59 | - $previousStepFile = $updaterFolderPath . '/.step-previous-update'; |
|
59 | + $previousStepFile = $updaterFolderPath . '/.step-previous-update'; |
|
60 | 60 | |
61 | - // cleanup |
|
62 | - if(file_exists($previousStepFile)) { |
|
63 | - if(\OC_Helper::rmdirr($previousStepFile)) { |
|
64 | - $output->info('.step-previous-update removed'); |
|
65 | - } else { |
|
66 | - $output->info('.step-previous-update can\'t be removed - abort move of .step file'); |
|
67 | - return; |
|
68 | - } |
|
69 | - } |
|
61 | + // cleanup |
|
62 | + if(file_exists($previousStepFile)) { |
|
63 | + if(\OC_Helper::rmdirr($previousStepFile)) { |
|
64 | + $output->info('.step-previous-update removed'); |
|
65 | + } else { |
|
66 | + $output->info('.step-previous-update can\'t be removed - abort move of .step file'); |
|
67 | + return; |
|
68 | + } |
|
69 | + } |
|
70 | 70 | |
71 | - // move step file |
|
72 | - if(rename($stepFile, $previousStepFile)) { |
|
73 | - $output->info('.step file moved to .step-previous-update'); |
|
74 | - } else { |
|
75 | - $output->warning('.step file can\'t be moved'); |
|
76 | - } |
|
77 | - } |
|
78 | - } |
|
71 | + // move step file |
|
72 | + if(rename($stepFile, $previousStepFile)) { |
|
73 | + $output->info('.step file moved to .step-previous-update'); |
|
74 | + } else { |
|
75 | + $output->warning('.step file can\'t be moved'); |
|
76 | + } |
|
77 | + } |
|
78 | + } |
|
79 | 79 | } |
80 | 80 |