@@ -33,55 +33,55 @@ |
||
33 | 33 | use OCP\Migration\SimpleMigrationStep; |
34 | 34 | |
35 | 35 | class Version1010Date20200630192639 extends SimpleMigrationStep { |
36 | - /** |
|
37 | - * @param IOutput $output |
|
38 | - * @param Closure $schemaClosure The `\Closure` returns a `ISchemaWrapper` |
|
39 | - * @param array $options |
|
40 | - * @return null|ISchemaWrapper |
|
41 | - */ |
|
42 | - public function changeSchema(IOutput $output, Closure $schemaClosure, array $options) { |
|
43 | - /** @var ISchemaWrapper $schema */ |
|
44 | - $schema = $schemaClosure(); |
|
36 | + /** |
|
37 | + * @param IOutput $output |
|
38 | + * @param Closure $schemaClosure The `\Closure` returns a `ISchemaWrapper` |
|
39 | + * @param array $options |
|
40 | + * @return null|ISchemaWrapper |
|
41 | + */ |
|
42 | + public function changeSchema(IOutput $output, Closure $schemaClosure, array $options) { |
|
43 | + /** @var ISchemaWrapper $schema */ |
|
44 | + $schema = $schemaClosure(); |
|
45 | 45 | |
46 | - if (!$schema->hasTable('files_trash')) { |
|
47 | - $table = $schema->createTable('files_trash'); |
|
48 | - $table->addColumn('auto_id', Types::BIGINT, [ |
|
49 | - 'autoincrement' => true, |
|
50 | - 'notnull' => true, |
|
51 | - ]); |
|
52 | - $table->addColumn('id', Types::STRING, [ |
|
53 | - 'notnull' => true, |
|
54 | - 'length' => 250, |
|
55 | - 'default' => '', |
|
56 | - ]); |
|
57 | - $table->addColumn('user', Types::STRING, [ |
|
58 | - 'notnull' => true, |
|
59 | - 'length' => 64, |
|
60 | - 'default' => '', |
|
61 | - ]); |
|
62 | - $table->addColumn('timestamp', Types::STRING, [ |
|
63 | - 'notnull' => true, |
|
64 | - 'length' => 12, |
|
65 | - 'default' => '', |
|
66 | - ]); |
|
67 | - $table->addColumn('location', Types::STRING, [ |
|
68 | - 'notnull' => true, |
|
69 | - 'length' => 512, |
|
70 | - 'default' => '', |
|
71 | - ]); |
|
72 | - $table->addColumn('type', Types::STRING, [ |
|
73 | - 'notnull' => false, |
|
74 | - 'length' => 4, |
|
75 | - ]); |
|
76 | - $table->addColumn('mime', Types::STRING, [ |
|
77 | - 'notnull' => false, |
|
78 | - 'length' => 255, |
|
79 | - ]); |
|
80 | - $table->setPrimaryKey(['auto_id']); |
|
81 | - $table->addIndex(['id'], 'id_index'); |
|
82 | - $table->addIndex(['timestamp'], 'timestamp_index'); |
|
83 | - $table->addIndex(['user'], 'user_index'); |
|
84 | - } |
|
85 | - return $schema; |
|
86 | - } |
|
46 | + if (!$schema->hasTable('files_trash')) { |
|
47 | + $table = $schema->createTable('files_trash'); |
|
48 | + $table->addColumn('auto_id', Types::BIGINT, [ |
|
49 | + 'autoincrement' => true, |
|
50 | + 'notnull' => true, |
|
51 | + ]); |
|
52 | + $table->addColumn('id', Types::STRING, [ |
|
53 | + 'notnull' => true, |
|
54 | + 'length' => 250, |
|
55 | + 'default' => '', |
|
56 | + ]); |
|
57 | + $table->addColumn('user', Types::STRING, [ |
|
58 | + 'notnull' => true, |
|
59 | + 'length' => 64, |
|
60 | + 'default' => '', |
|
61 | + ]); |
|
62 | + $table->addColumn('timestamp', Types::STRING, [ |
|
63 | + 'notnull' => true, |
|
64 | + 'length' => 12, |
|
65 | + 'default' => '', |
|
66 | + ]); |
|
67 | + $table->addColumn('location', Types::STRING, [ |
|
68 | + 'notnull' => true, |
|
69 | + 'length' => 512, |
|
70 | + 'default' => '', |
|
71 | + ]); |
|
72 | + $table->addColumn('type', Types::STRING, [ |
|
73 | + 'notnull' => false, |
|
74 | + 'length' => 4, |
|
75 | + ]); |
|
76 | + $table->addColumn('mime', Types::STRING, [ |
|
77 | + 'notnull' => false, |
|
78 | + 'length' => 255, |
|
79 | + ]); |
|
80 | + $table->setPrimaryKey(['auto_id']); |
|
81 | + $table->addIndex(['id'], 'id_index'); |
|
82 | + $table->addIndex(['timestamp'], 'timestamp_index'); |
|
83 | + $table->addIndex(['user'], 'user_index'); |
|
84 | + } |
|
85 | + return $schema; |
|
86 | + } |
|
87 | 87 | } |
@@ -34,70 +34,70 @@ |
||
34 | 34 | * usage: resource \OC\Files\Stream\Quota::wrap($stream, $limit) |
35 | 35 | */ |
36 | 36 | class Quota extends Wrapper { |
37 | - /** |
|
38 | - * @var int $limit |
|
39 | - */ |
|
40 | - private $limit; |
|
37 | + /** |
|
38 | + * @var int $limit |
|
39 | + */ |
|
40 | + private $limit; |
|
41 | 41 | |
42 | - /** |
|
43 | - * @param resource $stream |
|
44 | - * @param int $limit |
|
45 | - * @return bool|resource |
|
46 | - */ |
|
47 | - public static function wrap($stream, $limit) { |
|
48 | - $context = stream_context_create([ |
|
49 | - 'quota' => [ |
|
50 | - 'source' => $stream, |
|
51 | - 'limit' => $limit |
|
52 | - ] |
|
53 | - ]); |
|
54 | - return Wrapper::wrapSource($stream, $context, 'quota', self::class); |
|
55 | - } |
|
42 | + /** |
|
43 | + * @param resource $stream |
|
44 | + * @param int $limit |
|
45 | + * @return bool|resource |
|
46 | + */ |
|
47 | + public static function wrap($stream, $limit) { |
|
48 | + $context = stream_context_create([ |
|
49 | + 'quota' => [ |
|
50 | + 'source' => $stream, |
|
51 | + 'limit' => $limit |
|
52 | + ] |
|
53 | + ]); |
|
54 | + return Wrapper::wrapSource($stream, $context, 'quota', self::class); |
|
55 | + } |
|
56 | 56 | |
57 | - public function stream_open($path, $mode, $options, &$opened_path) { |
|
58 | - $context = $this->loadContext('quota'); |
|
59 | - $this->source = $context['source']; |
|
60 | - $this->limit = $context['limit']; |
|
57 | + public function stream_open($path, $mode, $options, &$opened_path) { |
|
58 | + $context = $this->loadContext('quota'); |
|
59 | + $this->source = $context['source']; |
|
60 | + $this->limit = $context['limit']; |
|
61 | 61 | |
62 | - return true; |
|
63 | - } |
|
62 | + return true; |
|
63 | + } |
|
64 | 64 | |
65 | - public function dir_opendir($path, $options) { |
|
66 | - return false; |
|
67 | - } |
|
65 | + public function dir_opendir($path, $options) { |
|
66 | + return false; |
|
67 | + } |
|
68 | 68 | |
69 | - public function stream_seek($offset, $whence = SEEK_SET) { |
|
70 | - if ($whence === SEEK_END) { |
|
71 | - // go to the end to find out last position's offset |
|
72 | - $oldOffset = $this->stream_tell(); |
|
73 | - if (fseek($this->source, 0, $whence) !== 0) { |
|
74 | - return false; |
|
75 | - } |
|
76 | - $whence = SEEK_SET; |
|
77 | - $offset = $this->stream_tell() + $offset; |
|
78 | - $this->limit += $oldOffset - $offset; |
|
79 | - } elseif ($whence === SEEK_SET) { |
|
80 | - $this->limit += $this->stream_tell() - $offset; |
|
81 | - } else { |
|
82 | - $this->limit -= $offset; |
|
83 | - } |
|
84 | - // this wrapper needs to return "true" for success. |
|
85 | - // the fseek call itself returns 0 on succeess |
|
86 | - return fseek($this->source, $offset, $whence) === 0; |
|
87 | - } |
|
69 | + public function stream_seek($offset, $whence = SEEK_SET) { |
|
70 | + if ($whence === SEEK_END) { |
|
71 | + // go to the end to find out last position's offset |
|
72 | + $oldOffset = $this->stream_tell(); |
|
73 | + if (fseek($this->source, 0, $whence) !== 0) { |
|
74 | + return false; |
|
75 | + } |
|
76 | + $whence = SEEK_SET; |
|
77 | + $offset = $this->stream_tell() + $offset; |
|
78 | + $this->limit += $oldOffset - $offset; |
|
79 | + } elseif ($whence === SEEK_SET) { |
|
80 | + $this->limit += $this->stream_tell() - $offset; |
|
81 | + } else { |
|
82 | + $this->limit -= $offset; |
|
83 | + } |
|
84 | + // this wrapper needs to return "true" for success. |
|
85 | + // the fseek call itself returns 0 on succeess |
|
86 | + return fseek($this->source, $offset, $whence) === 0; |
|
87 | + } |
|
88 | 88 | |
89 | - public function stream_read($count) { |
|
90 | - $this->limit -= $count; |
|
91 | - return fread($this->source, $count); |
|
92 | - } |
|
89 | + public function stream_read($count) { |
|
90 | + $this->limit -= $count; |
|
91 | + return fread($this->source, $count); |
|
92 | + } |
|
93 | 93 | |
94 | - public function stream_write($data) { |
|
95 | - $size = strlen($data); |
|
96 | - if ($size > $this->limit) { |
|
97 | - $data = substr($data, 0, $this->limit); |
|
98 | - $size = $this->limit; |
|
99 | - } |
|
100 | - $this->limit -= $size; |
|
101 | - return fwrite($this->source, $data); |
|
102 | - } |
|
94 | + public function stream_write($data) { |
|
95 | + $size = strlen($data); |
|
96 | + if ($size > $this->limit) { |
|
97 | + $data = substr($data, 0, $this->limit); |
|
98 | + $size = $this->limit; |
|
99 | + } |
|
100 | + $this->limit -= $size; |
|
101 | + return fwrite($this->source, $data); |
|
102 | + } |
|
103 | 103 | } |
@@ -34,37 +34,37 @@ |
||
34 | 34 | use OCP\Migration\SimpleMigrationStep; |
35 | 35 | |
36 | 36 | class Version21000Date20201223143245 extends SimpleMigrationStep { |
37 | - public function changeSchema(IOutput $output, Closure $schemaClosure, array $options): ?ISchemaWrapper { |
|
38 | - /** @var ISchemaWrapper $schema */ |
|
39 | - $schema = $schemaClosure(); |
|
37 | + public function changeSchema(IOutput $output, Closure $schemaClosure, array $options): ?ISchemaWrapper { |
|
38 | + /** @var ISchemaWrapper $schema */ |
|
39 | + $schema = $schemaClosure(); |
|
40 | 40 | |
41 | - if ($schema->hasTable('share_external')) { |
|
42 | - $table = $schema->getTable('share_external'); |
|
43 | - $changed = false; |
|
44 | - if (!$table->hasColumn('parent')) { |
|
45 | - $table->addColumn('parent', Types::BIGINT, [ |
|
46 | - 'notnull' => false, |
|
47 | - 'default' => -1, |
|
48 | - ]); |
|
49 | - $changed = true; |
|
50 | - } |
|
51 | - if (!$table->hasColumn('share_type')) { |
|
52 | - $table->addColumn('share_type', Types::INTEGER, [ |
|
53 | - 'notnull' => false, |
|
54 | - 'length' => 4, |
|
55 | - ]); |
|
56 | - $changed = true; |
|
57 | - } |
|
58 | - if ($table->hasColumn('lastscan')) { |
|
59 | - $table->dropColumn('lastscan'); |
|
60 | - $changed = true; |
|
61 | - } |
|
41 | + if ($schema->hasTable('share_external')) { |
|
42 | + $table = $schema->getTable('share_external'); |
|
43 | + $changed = false; |
|
44 | + if (!$table->hasColumn('parent')) { |
|
45 | + $table->addColumn('parent', Types::BIGINT, [ |
|
46 | + 'notnull' => false, |
|
47 | + 'default' => -1, |
|
48 | + ]); |
|
49 | + $changed = true; |
|
50 | + } |
|
51 | + if (!$table->hasColumn('share_type')) { |
|
52 | + $table->addColumn('share_type', Types::INTEGER, [ |
|
53 | + 'notnull' => false, |
|
54 | + 'length' => 4, |
|
55 | + ]); |
|
56 | + $changed = true; |
|
57 | + } |
|
58 | + if ($table->hasColumn('lastscan')) { |
|
59 | + $table->dropColumn('lastscan'); |
|
60 | + $changed = true; |
|
61 | + } |
|
62 | 62 | |
63 | - if ($changed) { |
|
64 | - return $schema; |
|
65 | - } |
|
66 | - } |
|
63 | + if ($changed) { |
|
64 | + return $schema; |
|
65 | + } |
|
66 | + } |
|
67 | 67 | |
68 | - return null; |
|
69 | - } |
|
68 | + return null; |
|
69 | + } |
|
70 | 70 | } |
@@ -49,110 +49,110 @@ |
||
49 | 49 | */ |
50 | 50 | |
51 | 51 | class File extends LogDetails implements IWriter, IFileBased { |
52 | - /** @var string */ |
|
53 | - protected $logFile; |
|
54 | - /** @var int */ |
|
55 | - protected $logFileMode; |
|
56 | - /** @var SystemConfig */ |
|
57 | - private $config; |
|
52 | + /** @var string */ |
|
53 | + protected $logFile; |
|
54 | + /** @var int */ |
|
55 | + protected $logFileMode; |
|
56 | + /** @var SystemConfig */ |
|
57 | + private $config; |
|
58 | 58 | |
59 | - public function __construct(string $path, string $fallbackPath, SystemConfig $config) { |
|
60 | - parent::__construct($config); |
|
61 | - $this->logFile = $path; |
|
62 | - if (!file_exists($this->logFile)) { |
|
63 | - if ( |
|
64 | - ( |
|
65 | - !is_writable(dirname($this->logFile)) |
|
66 | - || !touch($this->logFile) |
|
67 | - ) |
|
68 | - && $fallbackPath !== '' |
|
69 | - ) { |
|
70 | - $this->logFile = $fallbackPath; |
|
71 | - } |
|
72 | - } |
|
73 | - $this->config = $config; |
|
74 | - $this->logFileMode = $config->getValue('logfilemode', 0640); |
|
75 | - } |
|
59 | + public function __construct(string $path, string $fallbackPath, SystemConfig $config) { |
|
60 | + parent::__construct($config); |
|
61 | + $this->logFile = $path; |
|
62 | + if (!file_exists($this->logFile)) { |
|
63 | + if ( |
|
64 | + ( |
|
65 | + !is_writable(dirname($this->logFile)) |
|
66 | + || !touch($this->logFile) |
|
67 | + ) |
|
68 | + && $fallbackPath !== '' |
|
69 | + ) { |
|
70 | + $this->logFile = $fallbackPath; |
|
71 | + } |
|
72 | + } |
|
73 | + $this->config = $config; |
|
74 | + $this->logFileMode = $config->getValue('logfilemode', 0640); |
|
75 | + } |
|
76 | 76 | |
77 | - /** |
|
78 | - * write a message in the log |
|
79 | - * @param string $app |
|
80 | - * @param string|array $message |
|
81 | - * @param int $level |
|
82 | - */ |
|
83 | - public function write(string $app, $message, int $level) { |
|
84 | - $entry = $this->logDetailsAsJSON($app, $message, $level); |
|
85 | - $handle = @fopen($this->logFile, 'a'); |
|
86 | - if ($this->logFileMode > 0 && is_file($this->logFile) && (fileperms($this->logFile) & 0777) != $this->logFileMode) { |
|
87 | - @chmod($this->logFile, $this->logFileMode); |
|
88 | - } |
|
89 | - if ($handle) { |
|
90 | - fwrite($handle, $entry."\n"); |
|
91 | - fclose($handle); |
|
92 | - } else { |
|
93 | - // Fall back to error_log |
|
94 | - error_log($entry); |
|
95 | - } |
|
96 | - if (php_sapi_name() === 'cli-server') { |
|
97 | - if (!\is_string($message)) { |
|
98 | - $message = json_encode($message); |
|
99 | - } |
|
100 | - error_log($message, 4); |
|
101 | - } |
|
102 | - } |
|
77 | + /** |
|
78 | + * write a message in the log |
|
79 | + * @param string $app |
|
80 | + * @param string|array $message |
|
81 | + * @param int $level |
|
82 | + */ |
|
83 | + public function write(string $app, $message, int $level) { |
|
84 | + $entry = $this->logDetailsAsJSON($app, $message, $level); |
|
85 | + $handle = @fopen($this->logFile, 'a'); |
|
86 | + if ($this->logFileMode > 0 && is_file($this->logFile) && (fileperms($this->logFile) & 0777) != $this->logFileMode) { |
|
87 | + @chmod($this->logFile, $this->logFileMode); |
|
88 | + } |
|
89 | + if ($handle) { |
|
90 | + fwrite($handle, $entry."\n"); |
|
91 | + fclose($handle); |
|
92 | + } else { |
|
93 | + // Fall back to error_log |
|
94 | + error_log($entry); |
|
95 | + } |
|
96 | + if (php_sapi_name() === 'cli-server') { |
|
97 | + if (!\is_string($message)) { |
|
98 | + $message = json_encode($message); |
|
99 | + } |
|
100 | + error_log($message, 4); |
|
101 | + } |
|
102 | + } |
|
103 | 103 | |
104 | - /** |
|
105 | - * get entries from the log in reverse chronological order |
|
106 | - * @param int $limit |
|
107 | - * @param int $offset |
|
108 | - * @return array |
|
109 | - */ |
|
110 | - public function getEntries(int $limit = 50, int $offset = 0):array { |
|
111 | - $minLevel = $this->config->getValue("loglevel", ILogger::WARN); |
|
112 | - $entries = []; |
|
113 | - $handle = @fopen($this->logFile, 'rb'); |
|
114 | - if ($handle) { |
|
115 | - fseek($handle, 0, SEEK_END); |
|
116 | - $pos = ftell($handle); |
|
117 | - $line = ''; |
|
118 | - $entriesCount = 0; |
|
119 | - $lines = 0; |
|
120 | - // Loop through each character of the file looking for new lines |
|
121 | - while ($pos >= 0 && ($limit === null || $entriesCount < $limit)) { |
|
122 | - fseek($handle, $pos); |
|
123 | - $ch = fgetc($handle); |
|
124 | - if ($ch == "\n" || $pos == 0) { |
|
125 | - if ($line != '') { |
|
126 | - // Add the first character if at the start of the file, |
|
127 | - // because it doesn't hit the else in the loop |
|
128 | - if ($pos == 0) { |
|
129 | - $line = $ch.$line; |
|
130 | - } |
|
131 | - $entry = json_decode($line); |
|
132 | - // Add the line as an entry if it is passed the offset and is equal or above the log level |
|
133 | - if ($entry->level >= $minLevel) { |
|
134 | - $lines++; |
|
135 | - if ($lines > $offset) { |
|
136 | - $entries[] = $entry; |
|
137 | - $entriesCount++; |
|
138 | - } |
|
139 | - } |
|
140 | - $line = ''; |
|
141 | - } |
|
142 | - } else { |
|
143 | - $line = $ch.$line; |
|
144 | - } |
|
145 | - $pos--; |
|
146 | - } |
|
147 | - fclose($handle); |
|
148 | - } |
|
149 | - return $entries; |
|
150 | - } |
|
104 | + /** |
|
105 | + * get entries from the log in reverse chronological order |
|
106 | + * @param int $limit |
|
107 | + * @param int $offset |
|
108 | + * @return array |
|
109 | + */ |
|
110 | + public function getEntries(int $limit = 50, int $offset = 0):array { |
|
111 | + $minLevel = $this->config->getValue("loglevel", ILogger::WARN); |
|
112 | + $entries = []; |
|
113 | + $handle = @fopen($this->logFile, 'rb'); |
|
114 | + if ($handle) { |
|
115 | + fseek($handle, 0, SEEK_END); |
|
116 | + $pos = ftell($handle); |
|
117 | + $line = ''; |
|
118 | + $entriesCount = 0; |
|
119 | + $lines = 0; |
|
120 | + // Loop through each character of the file looking for new lines |
|
121 | + while ($pos >= 0 && ($limit === null || $entriesCount < $limit)) { |
|
122 | + fseek($handle, $pos); |
|
123 | + $ch = fgetc($handle); |
|
124 | + if ($ch == "\n" || $pos == 0) { |
|
125 | + if ($line != '') { |
|
126 | + // Add the first character if at the start of the file, |
|
127 | + // because it doesn't hit the else in the loop |
|
128 | + if ($pos == 0) { |
|
129 | + $line = $ch.$line; |
|
130 | + } |
|
131 | + $entry = json_decode($line); |
|
132 | + // Add the line as an entry if it is passed the offset and is equal or above the log level |
|
133 | + if ($entry->level >= $minLevel) { |
|
134 | + $lines++; |
|
135 | + if ($lines > $offset) { |
|
136 | + $entries[] = $entry; |
|
137 | + $entriesCount++; |
|
138 | + } |
|
139 | + } |
|
140 | + $line = ''; |
|
141 | + } |
|
142 | + } else { |
|
143 | + $line = $ch.$line; |
|
144 | + } |
|
145 | + $pos--; |
|
146 | + } |
|
147 | + fclose($handle); |
|
148 | + } |
|
149 | + return $entries; |
|
150 | + } |
|
151 | 151 | |
152 | - /** |
|
153 | - * @return string |
|
154 | - */ |
|
155 | - public function getLogFilePath():string { |
|
156 | - return $this->logFile; |
|
157 | - } |
|
152 | + /** |
|
153 | + * @return string |
|
154 | + */ |
|
155 | + public function getLogFilePath():string { |
|
156 | + return $this->logFile; |
|
157 | + } |
|
158 | 158 | } |
@@ -34,60 +34,60 @@ |
||
34 | 34 | * Person mount points can be moved by the user |
35 | 35 | */ |
36 | 36 | class PersonalMount extends ExternalMountPoint implements MoveableMount { |
37 | - /** @var UserStoragesService */ |
|
38 | - protected $storagesService; |
|
37 | + /** @var UserStoragesService */ |
|
38 | + protected $storagesService; |
|
39 | 39 | |
40 | - /** @var int */ |
|
41 | - protected $numericStorageId; |
|
40 | + /** @var int */ |
|
41 | + protected $numericStorageId; |
|
42 | 42 | |
43 | - /** |
|
44 | - * @param UserStoragesService $storagesService |
|
45 | - * @param int $storageId |
|
46 | - * @param IStorage $storage |
|
47 | - * @param string $mountpoint |
|
48 | - * @param array $arguments (optional) configuration for the storage backend |
|
49 | - * @param \OCP\Files\Storage\IStorageFactory $loader |
|
50 | - * @param array $mountOptions mount specific options |
|
51 | - */ |
|
52 | - public function __construct( |
|
53 | - UserStoragesService $storagesService, |
|
54 | - StorageConfig $storageConfig, |
|
55 | - $storageId, |
|
56 | - $storage, |
|
57 | - $mountpoint, |
|
58 | - $arguments = null, |
|
59 | - $loader = null, |
|
60 | - $mountOptions = null, |
|
61 | - $mountId = null |
|
62 | - ) { |
|
63 | - parent::__construct($storageConfig, $storage, $mountpoint, $arguments, $loader, $mountOptions, $mountId); |
|
64 | - $this->storagesService = $storagesService; |
|
65 | - $this->numericStorageId = $storageId; |
|
66 | - } |
|
43 | + /** |
|
44 | + * @param UserStoragesService $storagesService |
|
45 | + * @param int $storageId |
|
46 | + * @param IStorage $storage |
|
47 | + * @param string $mountpoint |
|
48 | + * @param array $arguments (optional) configuration for the storage backend |
|
49 | + * @param \OCP\Files\Storage\IStorageFactory $loader |
|
50 | + * @param array $mountOptions mount specific options |
|
51 | + */ |
|
52 | + public function __construct( |
|
53 | + UserStoragesService $storagesService, |
|
54 | + StorageConfig $storageConfig, |
|
55 | + $storageId, |
|
56 | + $storage, |
|
57 | + $mountpoint, |
|
58 | + $arguments = null, |
|
59 | + $loader = null, |
|
60 | + $mountOptions = null, |
|
61 | + $mountId = null |
|
62 | + ) { |
|
63 | + parent::__construct($storageConfig, $storage, $mountpoint, $arguments, $loader, $mountOptions, $mountId); |
|
64 | + $this->storagesService = $storagesService; |
|
65 | + $this->numericStorageId = $storageId; |
|
66 | + } |
|
67 | 67 | |
68 | - /** |
|
69 | - * Move the mount point to $target |
|
70 | - * |
|
71 | - * @param string $target the target mount point |
|
72 | - * @return bool |
|
73 | - */ |
|
74 | - public function moveMount($target) { |
|
75 | - $storage = $this->storagesService->getStorage($this->numericStorageId); |
|
76 | - // remove "/$user/files" prefix |
|
77 | - $targetParts = explode('/', trim($target, '/'), 3); |
|
78 | - $storage->setMountPoint($targetParts[2]); |
|
79 | - $this->storagesService->updateStorage($storage); |
|
80 | - $this->setMountPoint($target); |
|
81 | - return true; |
|
82 | - } |
|
68 | + /** |
|
69 | + * Move the mount point to $target |
|
70 | + * |
|
71 | + * @param string $target the target mount point |
|
72 | + * @return bool |
|
73 | + */ |
|
74 | + public function moveMount($target) { |
|
75 | + $storage = $this->storagesService->getStorage($this->numericStorageId); |
|
76 | + // remove "/$user/files" prefix |
|
77 | + $targetParts = explode('/', trim($target, '/'), 3); |
|
78 | + $storage->setMountPoint($targetParts[2]); |
|
79 | + $this->storagesService->updateStorage($storage); |
|
80 | + $this->setMountPoint($target); |
|
81 | + return true; |
|
82 | + } |
|
83 | 83 | |
84 | - /** |
|
85 | - * Remove the mount points |
|
86 | - * |
|
87 | - * @return bool |
|
88 | - */ |
|
89 | - public function removeMount() { |
|
90 | - $this->storagesService->removeStorage($this->numericStorageId); |
|
91 | - return true; |
|
92 | - } |
|
84 | + /** |
|
85 | + * Remove the mount points |
|
86 | + * |
|
87 | + * @return bool |
|
88 | + */ |
|
89 | + public function removeMount() { |
|
90 | + $this->storagesService->removeStorage($this->numericStorageId); |
|
91 | + return true; |
|
92 | + } |
|
93 | 93 | } |
@@ -34,59 +34,59 @@ |
||
34 | 34 | |
35 | 35 | class BuildCalendarSearchIndex implements IRepairStep { |
36 | 36 | |
37 | - /** @var IDBConnection */ |
|
38 | - private $db; |
|
37 | + /** @var IDBConnection */ |
|
38 | + private $db; |
|
39 | 39 | |
40 | - /** @var IJobList */ |
|
41 | - private $jobList; |
|
40 | + /** @var IJobList */ |
|
41 | + private $jobList; |
|
42 | 42 | |
43 | - /** @var IConfig */ |
|
44 | - private $config; |
|
43 | + /** @var IConfig */ |
|
44 | + private $config; |
|
45 | 45 | |
46 | - /** |
|
47 | - * @param IDBConnection $db |
|
48 | - * @param IJobList $jobList |
|
49 | - * @param IConfig $config |
|
50 | - */ |
|
51 | - public function __construct(IDBConnection $db, |
|
52 | - IJobList $jobList, |
|
53 | - IConfig $config) { |
|
54 | - $this->db = $db; |
|
55 | - $this->jobList = $jobList; |
|
56 | - $this->config = $config; |
|
57 | - } |
|
46 | + /** |
|
47 | + * @param IDBConnection $db |
|
48 | + * @param IJobList $jobList |
|
49 | + * @param IConfig $config |
|
50 | + */ |
|
51 | + public function __construct(IDBConnection $db, |
|
52 | + IJobList $jobList, |
|
53 | + IConfig $config) { |
|
54 | + $this->db = $db; |
|
55 | + $this->jobList = $jobList; |
|
56 | + $this->config = $config; |
|
57 | + } |
|
58 | 58 | |
59 | - /** |
|
60 | - * @return string |
|
61 | - */ |
|
62 | - public function getName() { |
|
63 | - return 'Registering building of calendar search index as background job'; |
|
64 | - } |
|
59 | + /** |
|
60 | + * @return string |
|
61 | + */ |
|
62 | + public function getName() { |
|
63 | + return 'Registering building of calendar search index as background job'; |
|
64 | + } |
|
65 | 65 | |
66 | - /** |
|
67 | - * @param IOutput $output |
|
68 | - */ |
|
69 | - public function run(IOutput $output) { |
|
70 | - // only run once |
|
71 | - if ($this->config->getAppValue('dav', 'buildCalendarSearchIndex') === 'yes') { |
|
72 | - $output->info('Repair step already executed'); |
|
73 | - return; |
|
74 | - } |
|
66 | + /** |
|
67 | + * @param IOutput $output |
|
68 | + */ |
|
69 | + public function run(IOutput $output) { |
|
70 | + // only run once |
|
71 | + if ($this->config->getAppValue('dav', 'buildCalendarSearchIndex') === 'yes') { |
|
72 | + $output->info('Repair step already executed'); |
|
73 | + return; |
|
74 | + } |
|
75 | 75 | |
76 | - $query = $this->db->getQueryBuilder(); |
|
77 | - $query->select($query->createFunction('MAX(' . $query->getColumnName('id') . ')')) |
|
78 | - ->from('calendarobjects'); |
|
79 | - $result = $query->execute(); |
|
80 | - $maxId = (int) $result->fetchOne(); |
|
81 | - $result->closeCursor(); |
|
76 | + $query = $this->db->getQueryBuilder(); |
|
77 | + $query->select($query->createFunction('MAX(' . $query->getColumnName('id') . ')')) |
|
78 | + ->from('calendarobjects'); |
|
79 | + $result = $query->execute(); |
|
80 | + $maxId = (int) $result->fetchOne(); |
|
81 | + $result->closeCursor(); |
|
82 | 82 | |
83 | - $output->info('Add background job'); |
|
84 | - $this->jobList->add(BuildCalendarSearchIndexBackgroundJob::class, [ |
|
85 | - 'offset' => 0, |
|
86 | - 'stopAt' => $maxId |
|
87 | - ]); |
|
83 | + $output->info('Add background job'); |
|
84 | + $this->jobList->add(BuildCalendarSearchIndexBackgroundJob::class, [ |
|
85 | + 'offset' => 0, |
|
86 | + 'stopAt' => $maxId |
|
87 | + ]); |
|
88 | 88 | |
89 | - // if all were done, no need to redo the repair during next upgrade |
|
90 | - $this->config->setAppValue('dav', 'buildCalendarSearchIndex', 'yes'); |
|
91 | - } |
|
89 | + // if all were done, no need to redo the repair during next upgrade |
|
90 | + $this->config->setAppValue('dav', 'buildCalendarSearchIndex', 'yes'); |
|
91 | + } |
|
92 | 92 | } |
@@ -31,62 +31,62 @@ |
||
31 | 31 | |
32 | 32 | class BuildSocialSearchIndex implements IRepairStep { |
33 | 33 | |
34 | - /** @var IDBConnection */ |
|
35 | - private $db; |
|
34 | + /** @var IDBConnection */ |
|
35 | + private $db; |
|
36 | 36 | |
37 | - /** @var IJobList */ |
|
38 | - private $jobList; |
|
37 | + /** @var IJobList */ |
|
38 | + private $jobList; |
|
39 | 39 | |
40 | - /** @var IConfig */ |
|
41 | - private $config; |
|
40 | + /** @var IConfig */ |
|
41 | + private $config; |
|
42 | 42 | |
43 | - /** |
|
44 | - * @param IDBConnection $db |
|
45 | - * @param IJobList $jobList |
|
46 | - * @param IConfig $config |
|
47 | - */ |
|
48 | - public function __construct(IDBConnection $db, |
|
49 | - IJobList $jobList, |
|
50 | - IConfig $config) { |
|
51 | - $this->db = $db; |
|
52 | - $this->jobList = $jobList; |
|
53 | - $this->config = $config; |
|
54 | - } |
|
43 | + /** |
|
44 | + * @param IDBConnection $db |
|
45 | + * @param IJobList $jobList |
|
46 | + * @param IConfig $config |
|
47 | + */ |
|
48 | + public function __construct(IDBConnection $db, |
|
49 | + IJobList $jobList, |
|
50 | + IConfig $config) { |
|
51 | + $this->db = $db; |
|
52 | + $this->jobList = $jobList; |
|
53 | + $this->config = $config; |
|
54 | + } |
|
55 | 55 | |
56 | - /** |
|
57 | - * @return string |
|
58 | - */ |
|
59 | - public function getName() { |
|
60 | - return 'Register building of social profile search index as background job'; |
|
61 | - } |
|
56 | + /** |
|
57 | + * @return string |
|
58 | + */ |
|
59 | + public function getName() { |
|
60 | + return 'Register building of social profile search index as background job'; |
|
61 | + } |
|
62 | 62 | |
63 | - /** |
|
64 | - * @param IOutput $output |
|
65 | - */ |
|
66 | - public function run(IOutput $output) { |
|
67 | - // only run once |
|
68 | - if ($this->config->getAppValue('dav', 'builtSocialSearchIndex') === 'yes') { |
|
69 | - $output->info('Repair step already executed'); |
|
70 | - return; |
|
71 | - } |
|
63 | + /** |
|
64 | + * @param IOutput $output |
|
65 | + */ |
|
66 | + public function run(IOutput $output) { |
|
67 | + // only run once |
|
68 | + if ($this->config->getAppValue('dav', 'builtSocialSearchIndex') === 'yes') { |
|
69 | + $output->info('Repair step already executed'); |
|
70 | + return; |
|
71 | + } |
|
72 | 72 | |
73 | - $query = $this->db->getQueryBuilder(); |
|
74 | - $query->select($query->func()->max('cardid')) |
|
75 | - ->from('cards_properties') |
|
76 | - ->where($query->expr()->eq('name', $query->createNamedParameter('X-SOCIALPROFILE'))); |
|
77 | - $maxId = (int)$query->execute()->fetchOne(); |
|
73 | + $query = $this->db->getQueryBuilder(); |
|
74 | + $query->select($query->func()->max('cardid')) |
|
75 | + ->from('cards_properties') |
|
76 | + ->where($query->expr()->eq('name', $query->createNamedParameter('X-SOCIALPROFILE'))); |
|
77 | + $maxId = (int)$query->execute()->fetchOne(); |
|
78 | 78 | |
79 | - if ($maxId === 0) { |
|
80 | - return; |
|
81 | - } |
|
79 | + if ($maxId === 0) { |
|
80 | + return; |
|
81 | + } |
|
82 | 82 | |
83 | - $output->info('Add background job'); |
|
84 | - $this->jobList->add(BuildSocialSearchIndexBackgroundJob::class, [ |
|
85 | - 'offset' => 0, |
|
86 | - 'stopAt' => $maxId |
|
87 | - ]); |
|
83 | + $output->info('Add background job'); |
|
84 | + $this->jobList->add(BuildSocialSearchIndexBackgroundJob::class, [ |
|
85 | + 'offset' => 0, |
|
86 | + 'stopAt' => $maxId |
|
87 | + ]); |
|
88 | 88 | |
89 | - // no need to redo the repair during next upgrade |
|
90 | - $this->config->setAppValue('dav', 'builtSocialSearchIndex', 'yes'); |
|
91 | - } |
|
89 | + // no need to redo the repair during next upgrade |
|
90 | + $this->config->setAppValue('dav', 'builtSocialSearchIndex', 'yes'); |
|
91 | + } |
|
92 | 92 | } |
@@ -42,62 +42,62 @@ |
||
42 | 42 | */ |
43 | 43 | class RegisterBuildReminderIndexBackgroundJob implements IRepairStep { |
44 | 44 | |
45 | - /** @var IDBConnection */ |
|
46 | - private $db; |
|
45 | + /** @var IDBConnection */ |
|
46 | + private $db; |
|
47 | 47 | |
48 | - /** @var IJobList */ |
|
49 | - private $jobList; |
|
48 | + /** @var IJobList */ |
|
49 | + private $jobList; |
|
50 | 50 | |
51 | - /** @var IConfig */ |
|
52 | - private $config; |
|
51 | + /** @var IConfig */ |
|
52 | + private $config; |
|
53 | 53 | |
54 | - /** @var string */ |
|
55 | - private const CONFIG_KEY = 'buildCalendarReminderIndex'; |
|
54 | + /** @var string */ |
|
55 | + private const CONFIG_KEY = 'buildCalendarReminderIndex'; |
|
56 | 56 | |
57 | - /** |
|
58 | - * @param IDBConnection $db |
|
59 | - * @param IJobList $jobList |
|
60 | - * @param IConfig $config |
|
61 | - */ |
|
62 | - public function __construct(IDBConnection $db, |
|
63 | - IJobList $jobList, |
|
64 | - IConfig $config) { |
|
65 | - $this->db = $db; |
|
66 | - $this->jobList = $jobList; |
|
67 | - $this->config = $config; |
|
68 | - } |
|
57 | + /** |
|
58 | + * @param IDBConnection $db |
|
59 | + * @param IJobList $jobList |
|
60 | + * @param IConfig $config |
|
61 | + */ |
|
62 | + public function __construct(IDBConnection $db, |
|
63 | + IJobList $jobList, |
|
64 | + IConfig $config) { |
|
65 | + $this->db = $db; |
|
66 | + $this->jobList = $jobList; |
|
67 | + $this->config = $config; |
|
68 | + } |
|
69 | 69 | |
70 | - /** |
|
71 | - * @return string |
|
72 | - */ |
|
73 | - public function getName() { |
|
74 | - return 'Registering building of calendar reminder index as background job'; |
|
75 | - } |
|
70 | + /** |
|
71 | + * @return string |
|
72 | + */ |
|
73 | + public function getName() { |
|
74 | + return 'Registering building of calendar reminder index as background job'; |
|
75 | + } |
|
76 | 76 | |
77 | - /** |
|
78 | - * @param IOutput $output |
|
79 | - */ |
|
80 | - public function run(IOutput $output) { |
|
81 | - // only run once |
|
82 | - if ($this->config->getAppValue('dav', self::CONFIG_KEY) === 'yes') { |
|
83 | - $output->info('Repair step already executed'); |
|
84 | - return; |
|
85 | - } |
|
77 | + /** |
|
78 | + * @param IOutput $output |
|
79 | + */ |
|
80 | + public function run(IOutput $output) { |
|
81 | + // only run once |
|
82 | + if ($this->config->getAppValue('dav', self::CONFIG_KEY) === 'yes') { |
|
83 | + $output->info('Repair step already executed'); |
|
84 | + return; |
|
85 | + } |
|
86 | 86 | |
87 | - $query = $this->db->getQueryBuilder(); |
|
88 | - $query->select($query->createFunction('MAX(' . $query->getColumnName('id') . ')')) |
|
89 | - ->from('calendarobjects'); |
|
90 | - $result = $query->execute(); |
|
91 | - $maxId = (int) $result->fetchOne(); |
|
92 | - $result->closeCursor(); |
|
87 | + $query = $this->db->getQueryBuilder(); |
|
88 | + $query->select($query->createFunction('MAX(' . $query->getColumnName('id') . ')')) |
|
89 | + ->from('calendarobjects'); |
|
90 | + $result = $query->execute(); |
|
91 | + $maxId = (int) $result->fetchOne(); |
|
92 | + $result->closeCursor(); |
|
93 | 93 | |
94 | - $output->info('Add background job'); |
|
95 | - $this->jobList->add(BuildReminderIndexBackgroundJob::class, [ |
|
96 | - 'offset' => 0, |
|
97 | - 'stopAt' => $maxId |
|
98 | - ]); |
|
94 | + $output->info('Add background job'); |
|
95 | + $this->jobList->add(BuildReminderIndexBackgroundJob::class, [ |
|
96 | + 'offset' => 0, |
|
97 | + 'stopAt' => $maxId |
|
98 | + ]); |
|
99 | 99 | |
100 | - // if all were done, no need to redo the repair during next upgrade |
|
101 | - $this->config->setAppValue('dav', self::CONFIG_KEY, 'yes'); |
|
102 | - } |
|
100 | + // if all were done, no need to redo the repair during next upgrade |
|
101 | + $this->config->setAppValue('dav', self::CONFIG_KEY, 'yes'); |
|
102 | + } |
|
103 | 103 | } |
@@ -31,42 +31,42 @@ |
||
31 | 31 | use Doctrine\DBAL\Events; |
32 | 32 | |
33 | 33 | class SQLiteSessionInit implements EventSubscriber { |
34 | - /** |
|
35 | - * @var bool |
|
36 | - */ |
|
37 | - private $caseSensitiveLike; |
|
34 | + /** |
|
35 | + * @var bool |
|
36 | + */ |
|
37 | + private $caseSensitiveLike; |
|
38 | 38 | |
39 | - /** |
|
40 | - * @var string |
|
41 | - */ |
|
42 | - private $journalMode; |
|
39 | + /** |
|
40 | + * @var string |
|
41 | + */ |
|
42 | + private $journalMode; |
|
43 | 43 | |
44 | - /** |
|
45 | - * Configure case sensitive like for each connection |
|
46 | - * |
|
47 | - * @param bool $caseSensitiveLike |
|
48 | - * @param string $journalMode |
|
49 | - */ |
|
50 | - public function __construct($caseSensitiveLike, $journalMode) { |
|
51 | - $this->caseSensitiveLike = $caseSensitiveLike; |
|
52 | - $this->journalMode = $journalMode; |
|
53 | - } |
|
44 | + /** |
|
45 | + * Configure case sensitive like for each connection |
|
46 | + * |
|
47 | + * @param bool $caseSensitiveLike |
|
48 | + * @param string $journalMode |
|
49 | + */ |
|
50 | + public function __construct($caseSensitiveLike, $journalMode) { |
|
51 | + $this->caseSensitiveLike = $caseSensitiveLike; |
|
52 | + $this->journalMode = $journalMode; |
|
53 | + } |
|
54 | 54 | |
55 | - /** |
|
56 | - * @param ConnectionEventArgs $args |
|
57 | - * @return void |
|
58 | - */ |
|
59 | - public function postConnect(ConnectionEventArgs $args) { |
|
60 | - $sensitive = $this->caseSensitiveLike ? 'true' : 'false'; |
|
61 | - $args->getConnection()->executeUpdate('PRAGMA case_sensitive_like = ' . $sensitive); |
|
62 | - $args->getConnection()->executeUpdate('PRAGMA journal_mode = ' . $this->journalMode); |
|
63 | - /** @var \Doctrine\DBAL\Driver\PDO\Connection $connection */ |
|
64 | - $connection = $args->getConnection()->getWrappedConnection(); |
|
65 | - $pdo = $connection->getWrappedConnection(); |
|
66 | - $pdo->sqliteCreateFunction('md5', 'md5', 1); |
|
67 | - } |
|
55 | + /** |
|
56 | + * @param ConnectionEventArgs $args |
|
57 | + * @return void |
|
58 | + */ |
|
59 | + public function postConnect(ConnectionEventArgs $args) { |
|
60 | + $sensitive = $this->caseSensitiveLike ? 'true' : 'false'; |
|
61 | + $args->getConnection()->executeUpdate('PRAGMA case_sensitive_like = ' . $sensitive); |
|
62 | + $args->getConnection()->executeUpdate('PRAGMA journal_mode = ' . $this->journalMode); |
|
63 | + /** @var \Doctrine\DBAL\Driver\PDO\Connection $connection */ |
|
64 | + $connection = $args->getConnection()->getWrappedConnection(); |
|
65 | + $pdo = $connection->getWrappedConnection(); |
|
66 | + $pdo->sqliteCreateFunction('md5', 'md5', 1); |
|
67 | + } |
|
68 | 68 | |
69 | - public function getSubscribedEvents() { |
|
70 | - return [Events::postConnect]; |
|
71 | - } |
|
69 | + public function getSubscribedEvents() { |
|
70 | + return [Events::postConnect]; |
|
71 | + } |
|
72 | 72 | } |