|
1
|
|
|
<?php |
|
2
|
|
|
/** |
|
3
|
|
|
* @copyright Copyright (c) 2016, ownCloud, Inc. |
|
4
|
|
|
* |
|
5
|
|
|
* @author Robin Appelman <[email protected]> |
|
6
|
|
|
* @author Roeland Jago Douma <[email protected]> |
|
7
|
|
|
* |
|
8
|
|
|
* @license AGPL-3.0 |
|
9
|
|
|
* |
|
10
|
|
|
* This code is free software: you can redistribute it and/or modify |
|
11
|
|
|
* it under the terms of the GNU Affero General Public License, version 3, |
|
12
|
|
|
* as published by the Free Software Foundation. |
|
13
|
|
|
* |
|
14
|
|
|
* This program is distributed in the hope that it will be useful, |
|
15
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of |
|
16
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
|
17
|
|
|
* GNU Affero General Public License for more details. |
|
18
|
|
|
* |
|
19
|
|
|
* You should have received a copy of the GNU Affero General Public License, version 3, |
|
20
|
|
|
* along with this program. If not, see <http://www.gnu.org/licenses/> |
|
21
|
|
|
* |
|
22
|
|
|
*/ |
|
23
|
|
|
|
|
24
|
|
|
namespace OC\Files\Cache; |
|
25
|
|
|
|
|
26
|
|
|
use OCP\Files\Cache\ICache; |
|
27
|
|
|
use OCP\Files\Cache\ICacheEntry; |
|
28
|
|
|
|
|
29
|
|
|
/** |
|
30
|
|
|
* Fallback implementation for moveFromCache |
|
31
|
|
|
*/ |
|
32
|
|
|
trait MoveFromCacheTrait { |
|
33
|
|
|
/** |
|
34
|
|
|
* store meta data for a file or folder |
|
35
|
|
|
* |
|
36
|
|
|
* @param string $file |
|
37
|
|
|
* @param array $data |
|
38
|
|
|
* |
|
39
|
|
|
* @return int file id |
|
40
|
|
|
* @throws \RuntimeException |
|
41
|
|
|
*/ |
|
42
|
|
|
abstract public function put($file, array $data); |
|
43
|
|
|
|
|
44
|
|
|
abstract public function copyFromCache(ICache $sourceCache, ICacheEntry $sourceEntry, string $targetPath): int; |
|
45
|
|
|
|
|
46
|
|
|
/** |
|
47
|
|
|
* Move a file or folder in the cache |
|
48
|
|
|
* |
|
49
|
|
|
* @param \OCP\Files\Cache\ICache $sourceCache |
|
50
|
|
|
* @param string $sourcePath |
|
51
|
|
|
* @param string $targetPath |
|
52
|
|
|
*/ |
|
53
|
|
|
public function moveFromCache(ICache $sourceCache, $sourcePath, $targetPath) { |
|
54
|
|
|
$sourceEntry = $sourceCache->get($sourcePath); |
|
55
|
|
|
|
|
56
|
|
|
$this->copyFromCache($sourceCache, $sourceEntry, $targetPath); |
|
57
|
|
|
|
|
58
|
|
|
$sourceCache->remove($sourcePath); |
|
59
|
|
|
} |
|
60
|
|
|
} |
|
61
|
|
|
|