Code Duplication    Length = 19-25 lines in 2 locations

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

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

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

@@ 633-651 (lines=19) @@
630
	 * @param string $targetInternalPath
631
	 * @return bool
632
	 */
633
	public function moveFromStorage(\OCP\Files\Storage $sourceStorage, $sourceInternalPath, $targetInternalPath) {
634
		if ($sourceStorage === $this) {
635
			return $this->rename($sourceInternalPath, $targetInternalPath);
636
		}
637
638
		if (!$sourceStorage->isDeletable($sourceInternalPath)) {
639
			return false;
640
		}
641
642
		$result = $this->copyFromStorage($sourceStorage, $sourceInternalPath, $targetInternalPath, true);
643
		if ($result) {
644
			if ($sourceStorage->is_dir($sourceInternalPath)) {
645
				$result &= $sourceStorage->rmdir($sourceInternalPath);
646
			} else {
647
				$result &= $sourceStorage->unlink($sourceInternalPath);
648
			}
649
		}
650
		return $result;
651
	}
652
653
	/**
654
	 * @inheritdoc