Code Duplication    Length = 19-25 lines in 2 locations

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

@@ 624-648 (lines=25) @@
621
	 * @param bool $preserveMtime
622
	 * @return bool
623
	 */
624
	public function moveFromStorage(Storage $sourceStorage, $sourceInternalPath, $targetInternalPath, $preserveMtime = true) {
625
		if ($sourceStorage === $this) {
626
			return $this->rename($sourceInternalPath, $targetInternalPath);
627
		}
628
629
		// TODO clean this up once the underlying moveFromStorage in OC\Files\Storage\Wrapper\Common is fixed:
630
		// - call $this->storage->moveFromStorage() instead of $this->copyBetweenStorage
631
		// - copy the file cache update from  $this->copyBetweenStorage to this method
632
		// - copy the copyKeys() call from  $this->copyBetweenStorage to this method
633
		// - remove $this->copyBetweenStorage
634
635
		if (!$sourceStorage->isDeletable($sourceInternalPath)) {
636
			return false;
637
		}
638
639
		$result = $this->copyBetweenStorage($sourceStorage, $sourceInternalPath, $targetInternalPath, $preserveMtime, true);
640
		if ($result) {
641
			if ($sourceStorage->is_dir($sourceInternalPath)) {
642
				$result &= $sourceStorage->rmdir($sourceInternalPath);
643
			} else {
644
				$result &= $sourceStorage->unlink($sourceInternalPath);
645
			}
646
		}
647
		return $result;
648
	}
649
650
	/**
651
	 * Set the flag to true, so that the file would be

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

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