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

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