Code Duplication    Length = 9-11 lines in 4 locations

lib/backend.php 2 locations

@@ 399-409 (lines=11) @@
396
		}
397
		// new note
398
		if (!$fileindb) {
399
			if ($FOLDER != '') {
400
				$tmpfile = $FOLDER . "/" . $name . ".htm";
401
				if ($group != '')
402
					$tmpfile = $FOLDER . "/[" . $group . "] " . $name . ".htm";
403
				if (!Filesystem::file_exists($tmpfile)) {
404
					Filesystem::touch($tmpfile);
405
				}
406
				if ($info = Filesystem::getFileInfo($tmpfile)) {
407
					$mtime = $info['mtime'];
408
				}
409
			}
410
			$this->db->executeQuery("INSERT INTO *PREFIX*ownnote (uid, name, grouping, mtime, note, shared) VALUES (?,?,?,?,?,?)", Array($uid, $name, $group, $mtime, '', ''));
411
			$ret = $this->db->lastInsertId('*PREFIX*ownnote');
412
		}
@@ 485-493 (lines=9) @@
482
		$name = $note['name'];
483
		$group = $note['grouping'];
484
485
		if ($FOLDER != '') {
486
			$tmpfile = $FOLDER . "/" . $name . ".htm";
487
			if ($group != '')
488
				$tmpfile = $FOLDER . "/[" . $group . "] " . $name . ".htm";
489
			Filesystem::file_put_contents($tmpfile, $content);
490
			if ($info = Filesystem::getFileInfo($tmpfile)) {
491
				$mtime = $info['mtime'];
492
			}
493
		}
494
		$this->db->executeQuery("UPDATE *PREFIX*ownnote set note='', mtime=? WHERE id=?", Array($mtime, $note['id']));
495
496
		$this->db->executeQuery("DELETE FROM *PREFIX*ownnote_parts WHERE id=?", Array($note['id']));

lib/Service/OwnNoteService.php 2 locations

@@ 102-110 (lines=9) @@
99
		$name = $note->getName();
100
		$content = $note->getNote();
101
102
		if ($FOLDER != '' && $name) {
103
			$tmpfile = $FOLDER . "/" . $name . ".htm";
104
			if ($group != '')
105
				$tmpfile = $FOLDER . "/[" . $group . "] " . $name . ".htm";
106
			Filesystem::file_put_contents($tmpfile, $content);
107
			if ($info = Filesystem::getFileInfo($tmpfile)) {
108
				$mtime = $info['mtime'];
109
			}
110
		}
111
112
		return $this->noteMapper->create($note);
113
	}
@@ 156-164 (lines=9) @@
153
//		if (!$this->checkPermissions(\OCP\Constants::PERMISSION_UPDATE, $note->getId())) {
154
//			return false;
155
//		}
156
		if ($FOLDER != '' && $name) {
157
			$tmpfile = $FOLDER . "/" . $name . ".htm";
158
			if ($group != '')
159
				$tmpfile = $FOLDER . "/[" . $group . "] " . $name . ".htm";
160
			Filesystem::file_put_contents($tmpfile, $content);
161
			if ($info = Filesystem::getFileInfo($tmpfile)) {
162
				$note->setMtime($info['mtime']);
163
			}
164
		}
165
		if(!$note->getId()){
166
			return $this->noteMapper->create($note);
167
		}