Code Duplication    Length = 19-25 lines in 2 locations

lib/private/Files/Storage/Wrapper/Encryption.php 1 location

@@ 598-622 (lines=25) @@
595
	 * @param bool $preserveMtime
596
	 * @return bool
597
	 */
598
	public function moveFromStorage(Storage $sourceStorage, $sourceInternalPath, $targetInternalPath, $preserveMtime = true) {
599
		if ($sourceStorage === $this) {
600
			return $this->rename($sourceInternalPath, $targetInternalPath);
601
		}
602
603
		// TODO clean this up once the underlying moveFromStorage in OC\Files\Storage\Wrapper\Common is fixed:
604
		// - call $this->storage->moveFromStorage() instead of $this->copyBetweenStorage
605
		// - copy the file cache update from  $this->copyBetweenStorage to this method
606
		// - copy the copyKeys() call from  $this->copyBetweenStorage to this method
607
		// - remove $this->copyBetweenStorage
608
609
		if (!$sourceStorage->isDeletable($sourceInternalPath)) {
610
			return false;
611
		}
612
613
		$result = $this->copyBetweenStorage($sourceStorage, $sourceInternalPath, $targetInternalPath, $preserveMtime, true);
614
		if ($result) {
615
			if ($sourceStorage->is_dir($sourceInternalPath)) {
616
				$result &= $sourceStorage->rmdir($sourceInternalPath);
617
			} else {
618
				$result &= $sourceStorage->unlink($sourceInternalPath);
619
			}
620
		}
621
		return $result;
622
	}
623
624
625
	/**

lib/private/Files/Storage/Common.php 1 location

@@ 598-616 (lines=19) @@
595
	 * @param string $targetInternalPath
596
	 * @return bool
597
	 */
598
	public function moveFromStorage(\OCP\Files\Storage $sourceStorage, $sourceInternalPath, $targetInternalPath) {
599
		if ($sourceStorage === $this) {
600
			return $this->rename($sourceInternalPath, $targetInternalPath);
601
		}
602
603
		if (!$sourceStorage->isDeletable($sourceInternalPath)) {
604
			return false;
605
		}
606
607
		$result = $this->copyFromStorage($sourceStorage, $sourceInternalPath, $targetInternalPath, true);
608
		if ($result) {
609
			if ($sourceStorage->is_dir($sourceInternalPath)) {
610
				$result &= $sourceStorage->rmdir($sourceInternalPath);
611
			} else {
612
				$result &= $sourceStorage->unlink($sourceInternalPath);
613
			}
614
		}
615
		return $result;
616
	}
617
618
	/**
619
	 * @inheritdoc