aboutsummaryrefslogtreecommitdiffstats
path: root/lib/private/Files/Cache/MoveFromCacheTrait.php
diff options
context:
space:
mode:
Diffstat (limited to 'lib/private/Files/Cache/MoveFromCacheTrait.php')
-rw-r--r--lib/private/Files/Cache/MoveFromCacheTrait.php60
1 files changed, 6 insertions, 54 deletions
diff --git a/lib/private/Files/Cache/MoveFromCacheTrait.php b/lib/private/Files/Cache/MoveFromCacheTrait.php
index 0f42b00df1c..db35c6bb7f8 100644
--- a/lib/private/Files/Cache/MoveFromCacheTrait.php
+++ b/lib/private/Files/Cache/MoveFromCacheTrait.php
@@ -1,26 +1,10 @@
<?php
+
/**
- * @copyright Copyright (c) 2016, ownCloud, Inc.
- *
- * @author Robin Appelman <robin@icewind.nl>
- * @author Roeland Jago Douma <roeland@famdouma.nl>
- *
- * @license AGPL-3.0
- *
- * This code is free software: you can redistribute it and/or modify
- * it under the terms of the GNU Affero General Public License, version 3,
- * as published by the Free Software Foundation.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU Affero General Public License for more details.
- *
- * You should have received a copy of the GNU Affero General Public License, version 3,
- * along with this program. If not, see <http://www.gnu.org/licenses/>
- *
+ * SPDX-FileCopyrightText: 2016-2024 Nextcloud GmbH and Nextcloud contributors
+ * SPDX-FileCopyrightText: 2016 ownCloud, Inc.
+ * SPDX-License-Identifier: AGPL-3.0-only
*/
-
namespace OC\Files\Cache;
use OCP\Files\Cache\ICache;
@@ -41,6 +25,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 +41,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(),
- ];
- }
}