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

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