1
|
|
|
<?php |
2
|
|
|
namespace phpbu\App\Backup\Collector; |
3
|
|
|
|
4
|
|
|
use Kunnu\Dropbox\Dropbox as DropboxApi; |
5
|
|
|
use Kunnu\Dropbox\Models\FolderMetadata; |
6
|
|
|
use phpbu\App\Backup\Collector; |
7
|
|
|
use phpbu\App\Backup\File; |
8
|
|
|
use phpbu\App\Backup\Path; |
9
|
|
|
use phpbu\App\Backup\Target; |
10
|
|
|
use phpbu\App\Util; |
11
|
|
|
|
12
|
|
|
/** |
13
|
|
|
* Dropbox class. |
14
|
|
|
* |
15
|
|
|
* @package phpbu |
16
|
|
|
* @subpackage Backup |
17
|
|
|
* @author Sebastian Feldmann <[email protected]> |
18
|
|
|
* @author Vitaly Baev <[email protected]> |
19
|
|
|
* @copyright Sebastian Feldmann <[email protected]> |
20
|
|
|
* @license https://opensource.org/licenses/MIT The MIT License (MIT) |
21
|
|
|
* @link http://phpbu.de/ |
22
|
|
|
* @since Class available since Release 5.1.0 |
23
|
|
|
*/ |
24
|
|
|
class Dropbox extends Remote implements Collector |
25
|
|
|
{ |
26
|
|
|
/** |
27
|
|
|
* @var DropboxApi |
28
|
|
|
*/ |
29
|
|
|
protected $client; |
30
|
|
|
|
31
|
|
|
/** |
32
|
|
|
* OpenStack constructor. |
33
|
|
|
* |
34
|
|
|
* @param \phpbu\App\Backup\Target $target |
35
|
|
|
* @param \phpbu\App\Backup\Path $path |
36
|
|
|
* @param \Kunnu\Dropbox\Dropbox $client |
37
|
|
|
*/ |
38
|
|
|
public function __construct(Target $target, Path $path, DropboxApi $client) |
39
|
|
|
{ |
40
|
|
|
$this->setUp($target, $path); |
41
|
|
|
$this->client = $client; |
42
|
|
|
} |
43
|
|
|
|
44
|
|
|
/** |
45
|
|
|
* Collect all created backups. |
46
|
1 |
|
*/ |
47
|
|
|
protected function collectBackups() |
48
|
1 |
|
{ |
49
|
1 |
|
$items = $this->client->listFolder( |
50
|
1 |
|
Util\Path::withTrailingSlash($this->path->getPathThatIsNotChanging()), |
51
|
1 |
|
[ |
52
|
|
|
'limit' => 100, |
53
|
|
|
'recursive' => true, |
54
|
|
|
] |
55
|
|
|
); |
56
|
|
|
/** @var \Kunnu\Dropbox\Models\FileMetadata $item */ |
57
|
|
|
foreach ($items->getItems() as $item) { |
58
|
1 |
|
// skip directories |
59
|
|
|
if ($item instanceof FolderMetadata) { |
60
|
1 |
|
continue; |
61
|
1 |
|
} |
62
|
|
View Code Duplication |
if ($this->isFileMatch($item->getPathDisplay())) { |
63
|
1 |
|
$file = new File\Dropbox($this->client, $item); |
64
|
|
|
$index = $this->getFileIndex($file); |
65
|
|
|
$this->files[$index] = $file; |
66
|
|
|
} |
67
|
1 |
|
} |
68
|
|
|
} |
69
|
|
|
} |
70
|
|
|
|