diff options
author | Robin Appelman <robin@icewind.nl> | 2021-03-08 18:49:08 +0100 |
---|---|---|
committer | Robin Appelman <robin@icewind.nl> | 2021-03-12 17:22:36 +0100 |
commit | d2bcb57a542b4119f47a687e2fbb6ee9f2525ddc (patch) | |
tree | af5530ed17ed0d9d61fd243495b2151534614650 /lib/private/Files/Cache/MoveFromCacheTrait.php | |
parent | 32551b9ff7978395ec7777f11320056ab8413432 (diff) | |
download | nextcloud-server-d2bcb57a542b4119f47a687e2fbb6ee9f2525ddc.tar.gz nextcloud-server-d2bcb57a542b4119f47a687e2fbb6ee9f2525ddc.zip |
add ICopyFromCache trait to expose existing implementation
Signed-off-by: Robin Appelman <robin@icewind.nl>
Diffstat (limited to 'lib/private/Files/Cache/MoveFromCacheTrait.php')
-rw-r--r-- | lib/private/Files/Cache/MoveFromCacheTrait.php | 36 |
1 files changed, 2 insertions, 34 deletions
diff --git a/lib/private/Files/Cache/MoveFromCacheTrait.php b/lib/private/Files/Cache/MoveFromCacheTrait.php index 0f42b00df1c..2f5bbfb7eea 100644 --- a/lib/private/Files/Cache/MoveFromCacheTrait.php +++ b/lib/private/Files/Cache/MoveFromCacheTrait.php @@ -41,6 +41,8 @@ trait MoveFromCacheTrait { */ abstract public function put($file, array $data); + abstract public function copyFromCache(ICache $sourceCache, ICacheEntry $sourceEntry, string $targetPath): int; + /** * Move a file or folder in the cache * @@ -55,38 +57,4 @@ trait MoveFromCacheTrait { $sourceCache->remove($sourcePath); } - - /** - * Copy a file or folder in the cache - * - * @param \OCP\Files\Cache\ICache $sourceCache - * @param ICacheEntry $sourceEntry - * @param string $targetPath - */ - public function copyFromCache(ICache $sourceCache, ICacheEntry $sourceEntry, $targetPath) { - $this->put($targetPath, $this->cacheEntryToArray($sourceEntry)); - if ($sourceEntry->getMimeType() === ICacheEntry::DIRECTORY_MIMETYPE) { - $folderContent = $sourceCache->getFolderContentsById($sourceEntry->getId()); - foreach ($folderContent as $subEntry) { - $subTargetPath = $targetPath . '/' . $subEntry->getName(); - $this->copyFromCache($sourceCache, $subEntry, $subTargetPath); - } - } - } - - private function cacheEntryToArray(ICacheEntry $entry) { - return [ - 'size' => $entry->getSize(), - 'mtime' => $entry->getMTime(), - 'storage_mtime' => $entry->getStorageMTime(), - 'mimetype' => $entry->getMimeType(), - 'mimepart' => $entry->getMimePart(), - 'etag' => $entry->getEtag(), - 'permissions' => $entry->getPermissions(), - 'encrypted' => $entry->isEncrypted(), - 'creation_time' => $entry->getCreationTime(), - 'upload_time' => $entry->getUploadTime(), - 'metadata_etag' => $entry->getMetadataEtag(), - ]; - } } |