Code Duplication    Length = 3-3 lines in 4 locations

lib/Controller/PublicFileHandlingController.php 1 location

@@ 102-104 (lines=3) @@
99
		$range = $this->request->getHeader('Range');
100
		if ($range !== '') {
101
			$matches = [];
102
			if (preg_match('/bytes=0-(\d+)$/', $range, $matches) === 0) {
103
				return new DataResponse(['message' => $this->l->t('Invalid range request')], Http::STATUS_REQUEST_RANGE_NOT_SATISFIABLE);
104
			}
105
			$range = (int)$matches[1];
106
		} else {
107
			$range = -1;

lib/Controller/FileHandlingController.php 3 locations

@@ 87-89 (lines=3) @@
84
				/** @var File $file */
85
				$file = $this->userFolder->get($path);
86
87
				if ($file instanceof Folder) {
88
					return new DataResponse(['message' => $this->l->t('You can not open a folder')], Http::STATUS_BAD_REQUEST);
89
				}
90
91
				// default of 4MB
92
				$maxSize = 4194304;
@@ 93-95 (lines=3) @@
90
91
				// default of 4MB
92
				$maxSize = 4194304;
93
				if ($file->getSize() > $maxSize) {
94
					return new DataResponse(['message' => (string)$this->l->t('This file is too big to be opened. Please download the file instead.')], Http::STATUS_BAD_REQUEST);
95
				}
96
				$fileContents = $file->getContent();
97
				if ($fileContents !== false) {
98
					$writable = $file->isUpdateable();
@@ 154-156 (lines=3) @@
151
				/** @var File $file */
152
				$file = $this->userFolder->get($path);
153
154
				if ($file instanceof Folder) {
155
					return new DataResponse(['message' => $this->l->t('You can not write to a folder')], Http::STATUS_BAD_REQUEST);
156
				}
157
158
				// Get file mtime
159
				$filemtime = $file->getMTime();