@@ -24,36 +24,36 @@ |
||
24 | 24 | use OCP\IL10N; |
25 | 25 | |
26 | 26 | abstract class Bundle { |
27 | - /** @var IL10N */ |
|
28 | - protected $l10n; |
|
27 | + /** @var IL10N */ |
|
28 | + protected $l10n; |
|
29 | 29 | |
30 | - /** |
|
31 | - * @param IL10N $l10n |
|
32 | - */ |
|
33 | - public function __construct(IL10N $l10n) { |
|
34 | - $this->l10n = $l10n; |
|
35 | - } |
|
30 | + /** |
|
31 | + * @param IL10N $l10n |
|
32 | + */ |
|
33 | + public function __construct(IL10N $l10n) { |
|
34 | + $this->l10n = $l10n; |
|
35 | + } |
|
36 | 36 | |
37 | - /** |
|
38 | - * Get the identifier of the bundle |
|
39 | - * |
|
40 | - * @return string |
|
41 | - */ |
|
42 | - final public function getIdentifier() { |
|
43 | - return substr(strrchr(get_class($this), '\\'), 1); |
|
44 | - } |
|
37 | + /** |
|
38 | + * Get the identifier of the bundle |
|
39 | + * |
|
40 | + * @return string |
|
41 | + */ |
|
42 | + final public function getIdentifier() { |
|
43 | + return substr(strrchr(get_class($this), '\\'), 1); |
|
44 | + } |
|
45 | 45 | |
46 | - /** |
|
47 | - * Get the name of the bundle |
|
48 | - * |
|
49 | - * @return string |
|
50 | - */ |
|
51 | - abstract public function getName(); |
|
46 | + /** |
|
47 | + * Get the name of the bundle |
|
48 | + * |
|
49 | + * @return string |
|
50 | + */ |
|
51 | + abstract public function getName(); |
|
52 | 52 | |
53 | - /** |
|
54 | - * Get the list of app identifiers in the bundle |
|
55 | - * |
|
56 | - * @return array |
|
57 | - */ |
|
58 | - abstract public function getAppIdentifiers(); |
|
53 | + /** |
|
54 | + * Get the list of app identifiers in the bundle |
|
55 | + * |
|
56 | + * @return array |
|
57 | + */ |
|
58 | + abstract public function getAppIdentifiers(); |
|
59 | 59 | } |
@@ -28,51 +28,51 @@ |
||
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) { |
|
46 | - $dataDir = $this->config->getSystemValue('datadirectory', \OC::$SERVERROOT . '/data'); |
|
47 | - $instanceId = $this->config->getSystemValue('instanceid', null); |
|
45 | + public function run(IOutput $output) { |
|
46 | + $dataDir = $this->config->getSystemValue('datadirectory', \OC::$SERVERROOT . '/data'); |
|
47 | + $instanceId = $this->config->getSystemValue('instanceid', null); |
|
48 | 48 | |
49 | - if (!is_string($instanceId) || empty($instanceId)) { |
|
50 | - return; |
|
51 | - } |
|
49 | + if (!is_string($instanceId) || empty($instanceId)) { |
|
50 | + return; |
|
51 | + } |
|
52 | 52 | |
53 | - $updaterFolderPath = $dataDir . '/updater-' . $instanceId; |
|
54 | - $stepFile = $updaterFolderPath . '/.step'; |
|
55 | - if (file_exists($stepFile)) { |
|
56 | - $output->info('.step file exists'); |
|
53 | + $updaterFolderPath = $dataDir . '/updater-' . $instanceId; |
|
54 | + $stepFile = $updaterFolderPath . '/.step'; |
|
55 | + if (file_exists($stepFile)) { |
|
56 | + $output->info('.step file exists'); |
|
57 | 57 | |
58 | - $previousStepFile = $updaterFolderPath . '/.step-previous-update'; |
|
58 | + $previousStepFile = $updaterFolderPath . '/.step-previous-update'; |
|
59 | 59 | |
60 | - // cleanup |
|
61 | - if (file_exists($previousStepFile)) { |
|
62 | - if (\OC_Helper::rmdirr($previousStepFile)) { |
|
63 | - $output->info('.step-previous-update removed'); |
|
64 | - } else { |
|
65 | - $output->info('.step-previous-update can\'t be removed - abort move of .step file'); |
|
66 | - return; |
|
67 | - } |
|
68 | - } |
|
60 | + // cleanup |
|
61 | + if (file_exists($previousStepFile)) { |
|
62 | + if (\OC_Helper::rmdirr($previousStepFile)) { |
|
63 | + $output->info('.step-previous-update removed'); |
|
64 | + } else { |
|
65 | + $output->info('.step-previous-update can\'t be removed - abort move of .step file'); |
|
66 | + return; |
|
67 | + } |
|
68 | + } |
|
69 | 69 | |
70 | - // move step file |
|
71 | - if (rename($stepFile, $previousStepFile)) { |
|
72 | - $output->info('.step file moved to .step-previous-update'); |
|
73 | - } else { |
|
74 | - $output->warning('.step file can\'t be moved'); |
|
75 | - } |
|
76 | - } |
|
77 | - } |
|
70 | + // move step file |
|
71 | + if (rename($stepFile, $previousStepFile)) { |
|
72 | + $output->info('.step file moved to .step-previous-update'); |
|
73 | + } else { |
|
74 | + $output->warning('.step file can\'t be moved'); |
|
75 | + } |
|
76 | + } |
|
77 | + } |
|
78 | 78 | } |
@@ -34,46 +34,46 @@ |
||
34 | 34 | * @package OC |
35 | 35 | */ |
36 | 36 | class HintException extends \Exception { |
37 | - private $hint; |
|
37 | + private $hint; |
|
38 | 38 | |
39 | - /** |
|
40 | - * HintException constructor. |
|
41 | - * |
|
42 | - * @param string $message The error message. It will be not revealed to the |
|
43 | - * the user (unless the hint is empty) and thus |
|
44 | - * should be not translated. |
|
45 | - * @param string $hint A useful message that is presented to the end |
|
46 | - * user. It should be translated, but must not |
|
47 | - * contain sensitive data. |
|
48 | - * @param int $code |
|
49 | - * @param \Exception|null $previous |
|
50 | - */ |
|
51 | - public function __construct($message, $hint = '', $code = 0, \Exception $previous = null) { |
|
52 | - $this->hint = $hint; |
|
53 | - parent::__construct($message, $code, $previous); |
|
54 | - } |
|
39 | + /** |
|
40 | + * HintException constructor. |
|
41 | + * |
|
42 | + * @param string $message The error message. It will be not revealed to the |
|
43 | + * the user (unless the hint is empty) and thus |
|
44 | + * should be not translated. |
|
45 | + * @param string $hint A useful message that is presented to the end |
|
46 | + * user. It should be translated, but must not |
|
47 | + * contain sensitive data. |
|
48 | + * @param int $code |
|
49 | + * @param \Exception|null $previous |
|
50 | + */ |
|
51 | + public function __construct($message, $hint = '', $code = 0, \Exception $previous = null) { |
|
52 | + $this->hint = $hint; |
|
53 | + parent::__construct($message, $code, $previous); |
|
54 | + } |
|
55 | 55 | |
56 | - /** |
|
57 | - * Returns a string representation of this Exception that includes the error |
|
58 | - * code, the message and the hint. |
|
59 | - * |
|
60 | - * @return string |
|
61 | - */ |
|
62 | - public function __toString() { |
|
63 | - return __CLASS__ . ": [{$this->code}]: {$this->message} ({$this->hint})\n"; |
|
64 | - } |
|
56 | + /** |
|
57 | + * Returns a string representation of this Exception that includes the error |
|
58 | + * code, the message and the hint. |
|
59 | + * |
|
60 | + * @return string |
|
61 | + */ |
|
62 | + public function __toString() { |
|
63 | + return __CLASS__ . ": [{$this->code}]: {$this->message} ({$this->hint})\n"; |
|
64 | + } |
|
65 | 65 | |
66 | - /** |
|
67 | - * Returns the hint with the intention to be presented to the end user. If |
|
68 | - * an empty hint was specified upon instatiation, the message is returned |
|
69 | - * instead. |
|
70 | - * |
|
71 | - * @return string |
|
72 | - */ |
|
73 | - public function getHint() { |
|
74 | - if (empty($this->hint)) { |
|
75 | - return $this->message; |
|
76 | - } |
|
77 | - return $this->hint; |
|
78 | - } |
|
66 | + /** |
|
67 | + * Returns the hint with the intention to be presented to the end user. If |
|
68 | + * an empty hint was specified upon instatiation, the message is returned |
|
69 | + * instead. |
|
70 | + * |
|
71 | + * @return string |
|
72 | + */ |
|
73 | + public function getHint() { |
|
74 | + if (empty($this->hint)) { |
|
75 | + return $this->message; |
|
76 | + } |
|
77 | + return $this->hint; |
|
78 | + } |
|
79 | 79 | } |
@@ -32,127 +32,127 @@ |
||
32 | 32 | |
33 | 33 | class Result { |
34 | 34 | |
35 | - /** @var array */ |
|
36 | - protected $data; |
|
37 | - |
|
38 | - /** @var null|string */ |
|
39 | - protected $message; |
|
40 | - |
|
41 | - /** @var int */ |
|
42 | - protected $statusCode; |
|
43 | - |
|
44 | - /** @var integer */ |
|
45 | - protected $items; |
|
46 | - |
|
47 | - /** @var integer */ |
|
48 | - protected $perPage; |
|
49 | - |
|
50 | - /** @var array */ |
|
51 | - private $headers = []; |
|
52 | - |
|
53 | - /** |
|
54 | - * create the OCS_Result object |
|
55 | - * @param mixed $data the data to return |
|
56 | - * @param int $code |
|
57 | - * @param null|string $message |
|
58 | - * @param array $headers |
|
59 | - */ |
|
60 | - public function __construct($data = null, $code = 100, $message = null, $headers = []) { |
|
61 | - if ($data === null) { |
|
62 | - $this->data = []; |
|
63 | - } elseif (!is_array($data)) { |
|
64 | - $this->data = [$this->data]; |
|
65 | - } else { |
|
66 | - $this->data = $data; |
|
67 | - } |
|
68 | - $this->statusCode = $code; |
|
69 | - $this->message = $message; |
|
70 | - $this->headers = $headers; |
|
71 | - } |
|
72 | - |
|
73 | - /** |
|
74 | - * optionally set the total number of items available |
|
75 | - * @param int $items |
|
76 | - */ |
|
77 | - public function setTotalItems($items) { |
|
78 | - $this->items = $items; |
|
79 | - } |
|
80 | - |
|
81 | - /** |
|
82 | - * optionally set the the number of items per page |
|
83 | - * @param int $items |
|
84 | - */ |
|
85 | - public function setItemsPerPage($items) { |
|
86 | - $this->perPage = $items; |
|
87 | - } |
|
88 | - |
|
89 | - /** |
|
90 | - * get the status code |
|
91 | - * @return int |
|
92 | - */ |
|
93 | - public function getStatusCode() { |
|
94 | - return $this->statusCode; |
|
95 | - } |
|
96 | - |
|
97 | - /** |
|
98 | - * get the meta data for the result |
|
99 | - * @return array |
|
100 | - */ |
|
101 | - public function getMeta() { |
|
102 | - $meta = []; |
|
103 | - $meta['status'] = $this->succeeded() ? 'ok' : 'failure'; |
|
104 | - $meta['statuscode'] = $this->statusCode; |
|
105 | - $meta['message'] = $this->message; |
|
106 | - if (isset($this->items)) { |
|
107 | - $meta['totalitems'] = $this->items; |
|
108 | - } |
|
109 | - if (isset($this->perPage)) { |
|
110 | - $meta['itemsperpage'] = $this->perPage; |
|
111 | - } |
|
112 | - return $meta; |
|
113 | - } |
|
114 | - |
|
115 | - /** |
|
116 | - * get the result data |
|
117 | - * @return array |
|
118 | - */ |
|
119 | - public function getData() { |
|
120 | - return $this->data; |
|
121 | - } |
|
122 | - |
|
123 | - /** |
|
124 | - * return bool Whether the method succeeded |
|
125 | - * @return bool |
|
126 | - */ |
|
127 | - public function succeeded() { |
|
128 | - return ($this->statusCode == 100); |
|
129 | - } |
|
130 | - |
|
131 | - /** |
|
132 | - * Adds a new header to the response |
|
133 | - * @param string $name The name of the HTTP header |
|
134 | - * @param string $value The value, null will delete it |
|
135 | - * @return $this |
|
136 | - */ |
|
137 | - public function addHeader($name, $value) { |
|
138 | - $name = trim($name); // always remove leading and trailing whitespace |
|
139 | - // to be able to reliably check for security |
|
140 | - // headers |
|
141 | - |
|
142 | - if (is_null($value)) { |
|
143 | - unset($this->headers[$name]); |
|
144 | - } else { |
|
145 | - $this->headers[$name] = $value; |
|
146 | - } |
|
147 | - |
|
148 | - return $this; |
|
149 | - } |
|
150 | - |
|
151 | - /** |
|
152 | - * Returns the set headers |
|
153 | - * @return array the headers |
|
154 | - */ |
|
155 | - public function getHeaders() { |
|
156 | - return $this->headers; |
|
157 | - } |
|
35 | + /** @var array */ |
|
36 | + protected $data; |
|
37 | + |
|
38 | + /** @var null|string */ |
|
39 | + protected $message; |
|
40 | + |
|
41 | + /** @var int */ |
|
42 | + protected $statusCode; |
|
43 | + |
|
44 | + /** @var integer */ |
|
45 | + protected $items; |
|
46 | + |
|
47 | + /** @var integer */ |
|
48 | + protected $perPage; |
|
49 | + |
|
50 | + /** @var array */ |
|
51 | + private $headers = []; |
|
52 | + |
|
53 | + /** |
|
54 | + * create the OCS_Result object |
|
55 | + * @param mixed $data the data to return |
|
56 | + * @param int $code |
|
57 | + * @param null|string $message |
|
58 | + * @param array $headers |
|
59 | + */ |
|
60 | + public function __construct($data = null, $code = 100, $message = null, $headers = []) { |
|
61 | + if ($data === null) { |
|
62 | + $this->data = []; |
|
63 | + } elseif (!is_array($data)) { |
|
64 | + $this->data = [$this->data]; |
|
65 | + } else { |
|
66 | + $this->data = $data; |
|
67 | + } |
|
68 | + $this->statusCode = $code; |
|
69 | + $this->message = $message; |
|
70 | + $this->headers = $headers; |
|
71 | + } |
|
72 | + |
|
73 | + /** |
|
74 | + * optionally set the total number of items available |
|
75 | + * @param int $items |
|
76 | + */ |
|
77 | + public function setTotalItems($items) { |
|
78 | + $this->items = $items; |
|
79 | + } |
|
80 | + |
|
81 | + /** |
|
82 | + * optionally set the the number of items per page |
|
83 | + * @param int $items |
|
84 | + */ |
|
85 | + public function setItemsPerPage($items) { |
|
86 | + $this->perPage = $items; |
|
87 | + } |
|
88 | + |
|
89 | + /** |
|
90 | + * get the status code |
|
91 | + * @return int |
|
92 | + */ |
|
93 | + public function getStatusCode() { |
|
94 | + return $this->statusCode; |
|
95 | + } |
|
96 | + |
|
97 | + /** |
|
98 | + * get the meta data for the result |
|
99 | + * @return array |
|
100 | + */ |
|
101 | + public function getMeta() { |
|
102 | + $meta = []; |
|
103 | + $meta['status'] = $this->succeeded() ? 'ok' : 'failure'; |
|
104 | + $meta['statuscode'] = $this->statusCode; |
|
105 | + $meta['message'] = $this->message; |
|
106 | + if (isset($this->items)) { |
|
107 | + $meta['totalitems'] = $this->items; |
|
108 | + } |
|
109 | + if (isset($this->perPage)) { |
|
110 | + $meta['itemsperpage'] = $this->perPage; |
|
111 | + } |
|
112 | + return $meta; |
|
113 | + } |
|
114 | + |
|
115 | + /** |
|
116 | + * get the result data |
|
117 | + * @return array |
|
118 | + */ |
|
119 | + public function getData() { |
|
120 | + return $this->data; |
|
121 | + } |
|
122 | + |
|
123 | + /** |
|
124 | + * return bool Whether the method succeeded |
|
125 | + * @return bool |
|
126 | + */ |
|
127 | + public function succeeded() { |
|
128 | + return ($this->statusCode == 100); |
|
129 | + } |
|
130 | + |
|
131 | + /** |
|
132 | + * Adds a new header to the response |
|
133 | + * @param string $name The name of the HTTP header |
|
134 | + * @param string $value The value, null will delete it |
|
135 | + * @return $this |
|
136 | + */ |
|
137 | + public function addHeader($name, $value) { |
|
138 | + $name = trim($name); // always remove leading and trailing whitespace |
|
139 | + // to be able to reliably check for security |
|
140 | + // headers |
|
141 | + |
|
142 | + if (is_null($value)) { |
|
143 | + unset($this->headers[$name]); |
|
144 | + } else { |
|
145 | + $this->headers[$name] = $value; |
|
146 | + } |
|
147 | + |
|
148 | + return $this; |
|
149 | + } |
|
150 | + |
|
151 | + /** |
|
152 | + * Returns the set headers |
|
153 | + * @return array the headers |
|
154 | + */ |
|
155 | + public function getHeaders() { |
|
156 | + return $this->headers; |
|
157 | + } |
|
158 | 158 | } |
@@ -29,20 +29,20 @@ |
||
29 | 29 | * local storage backend in temporary folder for testing purpose |
30 | 30 | */ |
31 | 31 | class Temporary extends Local { |
32 | - public function __construct($arguments = null) { |
|
33 | - parent::__construct(['datadir' => \OC::$server->getTempManager()->getTemporaryFolder()]); |
|
34 | - } |
|
32 | + public function __construct($arguments = null) { |
|
33 | + parent::__construct(['datadir' => \OC::$server->getTempManager()->getTemporaryFolder()]); |
|
34 | + } |
|
35 | 35 | |
36 | - public function cleanUp() { |
|
37 | - \OC_Helper::rmdirr($this->datadir); |
|
38 | - } |
|
36 | + public function cleanUp() { |
|
37 | + \OC_Helper::rmdirr($this->datadir); |
|
38 | + } |
|
39 | 39 | |
40 | - public function __destruct() { |
|
41 | - parent::__destruct(); |
|
42 | - $this->cleanUp(); |
|
43 | - } |
|
40 | + public function __destruct() { |
|
41 | + parent::__destruct(); |
|
42 | + $this->cleanUp(); |
|
43 | + } |
|
44 | 44 | |
45 | - public function getDataDir() { |
|
46 | - return $this->datadir; |
|
47 | - } |
|
45 | + public function getDataDir() { |
|
46 | + return $this->datadir; |
|
47 | + } |
|
48 | 48 | } |
@@ -33,70 +33,70 @@ |
||
33 | 33 | * usage: resource \OC\Files\Stream\Quota::wrap($stream, $limit) |
34 | 34 | */ |
35 | 35 | class Quota extends Wrapper { |
36 | - /** |
|
37 | - * @var int $limit |
|
38 | - */ |
|
39 | - private $limit; |
|
36 | + /** |
|
37 | + * @var int $limit |
|
38 | + */ |
|
39 | + private $limit; |
|
40 | 40 | |
41 | - /** |
|
42 | - * @param resource $stream |
|
43 | - * @param int $limit |
|
44 | - * @return resource |
|
45 | - */ |
|
46 | - public static function wrap($stream, $limit) { |
|
47 | - $context = stream_context_create([ |
|
48 | - 'quota' => [ |
|
49 | - 'source' => $stream, |
|
50 | - 'limit' => $limit |
|
51 | - ] |
|
52 | - ]); |
|
53 | - return Wrapper::wrapSource($stream, $context, 'quota', self::class); |
|
54 | - } |
|
41 | + /** |
|
42 | + * @param resource $stream |
|
43 | + * @param int $limit |
|
44 | + * @return resource |
|
45 | + */ |
|
46 | + public static function wrap($stream, $limit) { |
|
47 | + $context = stream_context_create([ |
|
48 | + 'quota' => [ |
|
49 | + 'source' => $stream, |
|
50 | + 'limit' => $limit |
|
51 | + ] |
|
52 | + ]); |
|
53 | + return Wrapper::wrapSource($stream, $context, 'quota', self::class); |
|
54 | + } |
|
55 | 55 | |
56 | - public function stream_open($path, $mode, $options, &$opened_path) { |
|
57 | - $context = $this->loadContext('quota'); |
|
58 | - $this->source = $context['source']; |
|
59 | - $this->limit = $context['limit']; |
|
56 | + public function stream_open($path, $mode, $options, &$opened_path) { |
|
57 | + $context = $this->loadContext('quota'); |
|
58 | + $this->source = $context['source']; |
|
59 | + $this->limit = $context['limit']; |
|
60 | 60 | |
61 | - return true; |
|
62 | - } |
|
61 | + return true; |
|
62 | + } |
|
63 | 63 | |
64 | - public function dir_opendir($path, $options) { |
|
65 | - return false; |
|
66 | - } |
|
64 | + public function dir_opendir($path, $options) { |
|
65 | + return false; |
|
66 | + } |
|
67 | 67 | |
68 | - public function stream_seek($offset, $whence = SEEK_SET) { |
|
69 | - if ($whence === SEEK_END) { |
|
70 | - // go to the end to find out last position's offset |
|
71 | - $oldOffset = $this->stream_tell(); |
|
72 | - if (fseek($this->source, 0, $whence) !== 0) { |
|
73 | - return false; |
|
74 | - } |
|
75 | - $whence = SEEK_SET; |
|
76 | - $offset = $this->stream_tell() + $offset; |
|
77 | - $this->limit += $oldOffset - $offset; |
|
78 | - } elseif ($whence === SEEK_SET) { |
|
79 | - $this->limit += $this->stream_tell() - $offset; |
|
80 | - } else { |
|
81 | - $this->limit -= $offset; |
|
82 | - } |
|
83 | - // this wrapper needs to return "true" for success. |
|
84 | - // the fseek call itself returns 0 on succeess |
|
85 | - return fseek($this->source, $offset, $whence) === 0; |
|
86 | - } |
|
68 | + public function stream_seek($offset, $whence = SEEK_SET) { |
|
69 | + if ($whence === SEEK_END) { |
|
70 | + // go to the end to find out last position's offset |
|
71 | + $oldOffset = $this->stream_tell(); |
|
72 | + if (fseek($this->source, 0, $whence) !== 0) { |
|
73 | + return false; |
|
74 | + } |
|
75 | + $whence = SEEK_SET; |
|
76 | + $offset = $this->stream_tell() + $offset; |
|
77 | + $this->limit += $oldOffset - $offset; |
|
78 | + } elseif ($whence === SEEK_SET) { |
|
79 | + $this->limit += $this->stream_tell() - $offset; |
|
80 | + } else { |
|
81 | + $this->limit -= $offset; |
|
82 | + } |
|
83 | + // this wrapper needs to return "true" for success. |
|
84 | + // the fseek call itself returns 0 on succeess |
|
85 | + return fseek($this->source, $offset, $whence) === 0; |
|
86 | + } |
|
87 | 87 | |
88 | - public function stream_read($count) { |
|
89 | - $this->limit -= $count; |
|
90 | - return fread($this->source, $count); |
|
91 | - } |
|
88 | + public function stream_read($count) { |
|
89 | + $this->limit -= $count; |
|
90 | + return fread($this->source, $count); |
|
91 | + } |
|
92 | 92 | |
93 | - public function stream_write($data) { |
|
94 | - $size = strlen($data); |
|
95 | - if ($size > $this->limit) { |
|
96 | - $data = substr($data, 0, $this->limit); |
|
97 | - $size = $this->limit; |
|
98 | - } |
|
99 | - $this->limit -= $size; |
|
100 | - return fwrite($this->source, $data); |
|
101 | - } |
|
93 | + public function stream_write($data) { |
|
94 | + $size = strlen($data); |
|
95 | + if ($size > $this->limit) { |
|
96 | + $data = substr($data, 0, $this->limit); |
|
97 | + $size = $this->limit; |
|
98 | + } |
|
99 | + $this->limit -= $size; |
|
100 | + return fwrite($this->source, $data); |
|
101 | + } |
|
102 | 102 | } |
@@ -28,40 +28,40 @@ |
||
28 | 28 | |
29 | 29 | class HomeObjectStoreStorage extends ObjectStoreStorage implements \OCP\Files\IHomeStorage { |
30 | 30 | |
31 | - /** |
|
32 | - * The home user storage requires a user object to create a unique storage id |
|
33 | - * @param array $params |
|
34 | - */ |
|
35 | - public function __construct($params) { |
|
36 | - if (! isset($params['user']) || ! $params['user'] instanceof User) { |
|
37 | - throw new \Exception('missing user object in parameters'); |
|
38 | - } |
|
39 | - $this->user = $params['user']; |
|
40 | - parent::__construct($params); |
|
41 | - } |
|
31 | + /** |
|
32 | + * The home user storage requires a user object to create a unique storage id |
|
33 | + * @param array $params |
|
34 | + */ |
|
35 | + public function __construct($params) { |
|
36 | + if (! isset($params['user']) || ! $params['user'] instanceof User) { |
|
37 | + throw new \Exception('missing user object in parameters'); |
|
38 | + } |
|
39 | + $this->user = $params['user']; |
|
40 | + parent::__construct($params); |
|
41 | + } |
|
42 | 42 | |
43 | - public function getId() { |
|
44 | - return 'object::user:' . $this->user->getUID(); |
|
45 | - } |
|
43 | + public function getId() { |
|
44 | + return 'object::user:' . $this->user->getUID(); |
|
45 | + } |
|
46 | 46 | |
47 | - /** |
|
48 | - * get the owner of a path |
|
49 | - * |
|
50 | - * @param string $path The path to get the owner |
|
51 | - * @return false|string uid |
|
52 | - */ |
|
53 | - public function getOwner($path) { |
|
54 | - if (is_object($this->user)) { |
|
55 | - return $this->user->getUID(); |
|
56 | - } |
|
57 | - return false; |
|
58 | - } |
|
47 | + /** |
|
48 | + * get the owner of a path |
|
49 | + * |
|
50 | + * @param string $path The path to get the owner |
|
51 | + * @return false|string uid |
|
52 | + */ |
|
53 | + public function getOwner($path) { |
|
54 | + if (is_object($this->user)) { |
|
55 | + return $this->user->getUID(); |
|
56 | + } |
|
57 | + return false; |
|
58 | + } |
|
59 | 59 | |
60 | - /** |
|
61 | - * @param string $path, optional |
|
62 | - * @return \OC\User\User |
|
63 | - */ |
|
64 | - public function getUser($path = null) { |
|
65 | - return $this->user; |
|
66 | - } |
|
60 | + /** |
|
61 | + * @param string $path, optional |
|
62 | + * @return \OC\User\User |
|
63 | + */ |
|
64 | + public function getUser($path = null) { |
|
65 | + return $this->user; |
|
66 | + } |
|
67 | 67 | } |
@@ -30,58 +30,58 @@ |
||
30 | 30 | use OCP\Files\Cache\ICacheEntry; |
31 | 31 | |
32 | 32 | class HomeCache extends Cache { |
33 | - /** |
|
34 | - * get the size of a folder and set it in the cache |
|
35 | - * |
|
36 | - * @param string $path |
|
37 | - * @param array $entry (optional) meta data of the folder |
|
38 | - * @return int |
|
39 | - */ |
|
40 | - public function calculateFolderSize($path, $entry = null) { |
|
41 | - if ($path !== '/' and $path !== '' and $path !== 'files' and $path !== 'files_trashbin' and $path !== 'files_versions') { |
|
42 | - return parent::calculateFolderSize($path, $entry); |
|
43 | - } elseif ($path === '' or $path === '/') { |
|
44 | - // since the size of / isn't used (the size of /files is used instead) there is no use in calculating it |
|
45 | - return 0; |
|
46 | - } |
|
33 | + /** |
|
34 | + * get the size of a folder and set it in the cache |
|
35 | + * |
|
36 | + * @param string $path |
|
37 | + * @param array $entry (optional) meta data of the folder |
|
38 | + * @return int |
|
39 | + */ |
|
40 | + public function calculateFolderSize($path, $entry = null) { |
|
41 | + if ($path !== '/' and $path !== '' and $path !== 'files' and $path !== 'files_trashbin' and $path !== 'files_versions') { |
|
42 | + return parent::calculateFolderSize($path, $entry); |
|
43 | + } elseif ($path === '' or $path === '/') { |
|
44 | + // since the size of / isn't used (the size of /files is used instead) there is no use in calculating it |
|
45 | + return 0; |
|
46 | + } |
|
47 | 47 | |
48 | - $totalSize = 0; |
|
49 | - if (is_null($entry)) { |
|
50 | - $entry = $this->get($path); |
|
51 | - } |
|
52 | - if ($entry && $entry['mimetype'] === 'httpd/unix-directory') { |
|
53 | - $id = $entry['fileid']; |
|
54 | - $sql = 'SELECT SUM(`size`) AS f1 ' . |
|
55 | - 'FROM `*PREFIX*filecache` ' . |
|
56 | - 'WHERE `parent` = ? AND `storage` = ? AND `size` >= 0'; |
|
57 | - $result = \OC_DB::executeAudited($sql, [$id, $this->getNumericStorageId()]); |
|
58 | - if ($row = $result->fetchRow()) { |
|
59 | - $result->closeCursor(); |
|
60 | - list($sum) = array_values($row); |
|
61 | - $totalSize = 0 + $sum; |
|
62 | - $entry['size'] += 0; |
|
63 | - if ($entry['size'] !== $totalSize) { |
|
64 | - $this->update($id, ['size' => $totalSize]); |
|
65 | - } |
|
66 | - } |
|
67 | - } |
|
68 | - return $totalSize; |
|
69 | - } |
|
48 | + $totalSize = 0; |
|
49 | + if (is_null($entry)) { |
|
50 | + $entry = $this->get($path); |
|
51 | + } |
|
52 | + if ($entry && $entry['mimetype'] === 'httpd/unix-directory') { |
|
53 | + $id = $entry['fileid']; |
|
54 | + $sql = 'SELECT SUM(`size`) AS f1 ' . |
|
55 | + 'FROM `*PREFIX*filecache` ' . |
|
56 | + 'WHERE `parent` = ? AND `storage` = ? AND `size` >= 0'; |
|
57 | + $result = \OC_DB::executeAudited($sql, [$id, $this->getNumericStorageId()]); |
|
58 | + if ($row = $result->fetchRow()) { |
|
59 | + $result->closeCursor(); |
|
60 | + list($sum) = array_values($row); |
|
61 | + $totalSize = 0 + $sum; |
|
62 | + $entry['size'] += 0; |
|
63 | + if ($entry['size'] !== $totalSize) { |
|
64 | + $this->update($id, ['size' => $totalSize]); |
|
65 | + } |
|
66 | + } |
|
67 | + } |
|
68 | + return $totalSize; |
|
69 | + } |
|
70 | 70 | |
71 | - /** |
|
72 | - * @param string $path |
|
73 | - * @return ICacheEntry |
|
74 | - */ |
|
75 | - public function get($path) { |
|
76 | - $data = parent::get($path); |
|
77 | - if ($path === '' or $path === '/') { |
|
78 | - // only the size of the "files" dir counts |
|
79 | - $filesData = parent::get('files'); |
|
71 | + /** |
|
72 | + * @param string $path |
|
73 | + * @return ICacheEntry |
|
74 | + */ |
|
75 | + public function get($path) { |
|
76 | + $data = parent::get($path); |
|
77 | + if ($path === '' or $path === '/') { |
|
78 | + // only the size of the "files" dir counts |
|
79 | + $filesData = parent::get('files'); |
|
80 | 80 | |
81 | - if (isset($filesData['size'])) { |
|
82 | - $data['size'] = $filesData['size']; |
|
83 | - } |
|
84 | - } |
|
85 | - return $data; |
|
86 | - } |
|
81 | + if (isset($filesData['size'])) { |
|
82 | + $data['size'] = $filesData['size']; |
|
83 | + } |
|
84 | + } |
|
85 | + return $data; |
|
86 | + } |
|
87 | 87 | } |
@@ -24,17 +24,17 @@ |
||
24 | 24 | namespace OC\DB; |
25 | 25 | |
26 | 26 | class MigrationException extends \Exception { |
27 | - private $table; |
|
27 | + private $table; |
|
28 | 28 | |
29 | - public function __construct($table, $message) { |
|
30 | - $this->table = $table; |
|
31 | - parent::__construct($message); |
|
32 | - } |
|
29 | + public function __construct($table, $message) { |
|
30 | + $this->table = $table; |
|
31 | + parent::__construct($message); |
|
32 | + } |
|
33 | 33 | |
34 | - /** |
|
35 | - * @return string |
|
36 | - */ |
|
37 | - public function getTable() { |
|
38 | - return $this->table; |
|
39 | - } |
|
34 | + /** |
|
35 | + * @return string |
|
36 | + */ |
|
37 | + public function getTable() { |
|
38 | + return $this->table; |
|
39 | + } |
|
40 | 40 | } |