Code Duplication    Length = 12-13 lines in 2 locations

lib/private/Files/Node/Folder.php 1 location

@@ 303-314 (lines=12) @@
300
		return $this->view->free_space($this->path);
301
	}
302
303
	public function delete() {
304
		if ($this->checkPermissions(\OCP\Constants::PERMISSION_DELETE)) {
305
			$this->sendHooks(['preDelete']);
306
			$fileInfo = $this->getFileInfo();
307
			$this->view->rmdir($this->path);
308
			$nonExisting = new NonExistingFolder($this->root, $this->view, $this->path, $fileInfo);
309
			$this->root->emit('\OC\Files', 'postDelete', [$nonExisting]);
310
			$this->exists = false;
311
		} else {
312
			throw new NotPermittedException('No delete permission for path ' . $this->getFullPath($this->path));
313
		}
314
	}
315
316
	/**
317
	 * Add a suffix to the name in case the file exists

lib/private/Files/Node/File.php 1 location

@@ 85-97 (lines=13) @@
82
		throw new \BadMethodCallException('fopen is no longer allowed to be called');
83
	}
84
85
	public function delete() {
86
		if (!$this->checkPermissions(\OCP\Constants::PERMISSION_DELETE)) {
87
			throw new NotPermittedException();
88
		}
89
90
		$this->sendHooks(['preDelete']);
91
		$fileInfo = $this->getFileInfo();
92
		$this->view->unlink($this->path);
93
		$nonExisting = new NonExistingFile($this->root, $this->view, $this->path, $fileInfo);
94
		$this->root->emit('\OC\Files', 'postDelete', [$nonExisting]);
95
		$this->exists = false;
96
		$this->fileInfo = null;
97
	}
98
99
	/**
100
	 * @param string $type