Code Duplication    Length = 3-3 lines in 6 locations

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();

lib/Controller/PublicFileHandlingController.php 3 locations

@@ 95-97 (lines=3) @@
92
			return new DataResponse(['message' => $this->l->t('Share not found'), Http::STATUS_NOT_FOUND]);
93
		}
94
95
		if ($node instanceof Folder) {
96
			return new DataResponse(['message' => $this->l->t('You can not open a folder')], Http::STATUS_BAD_REQUEST);
97
		}
98
99
		$range = $this->request->getHeader('Range');
100
		if ($range !== '') {
@@ 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;
@@ 112-114 (lines=3) @@
109
110
		// default of 4MB
111
		$maxSize = 4194304;
112
		if ($node->getSize() > $maxSize) {
113
			return new DataResponse(['message' => $this->l->t('This file is too big to be opened. Please download the file instead.')], Http::STATUS_BAD_REQUEST);
114
		}
115
116
		$fileContents = $node->getContent();
117
		if ($fileContents !== false) {