BackupGuard
6 years ago
Dropbox
6 years ago
Request
6 years ago
SGArchive.php
6 years ago
SGAuthClient.php
6 years ago
SGCallback.php
6 years ago
SGCdrEntry.php
6 years ago
SGCharsetHandler.php
6 years ago
SGDBState.php
6 years ago
SGEntry.php
6 years ago
SGFileEntry.php
6 years ago
SGFileState.php
6 years ago
SGMigrateState.php
6 years ago
SGMysqldump.php
6 years ago
SGReloadHandler.php
6 years ago
SGReloader.php
6 years ago
SGReloaderState.php
6 years ago
SGReviewManager.php
6 years ago
SGState.php
6 years ago
SGUploadHandler.php
6 years ago
SGUploadState.php
6 years ago
SGUploadState.php
125 lines
| 1 | <?php |
| 2 | |
| 3 | require_once(dirname(__FILE__).'/SGState.php'); |
| 4 | |
| 5 | class SGUploadState extends SGState |
| 6 | { |
| 7 | private $activeDirectory = ''; |
| 8 | private $currentUploadChunksCount = 0; |
| 9 | private $totalUploadChunksCount = 0; |
| 10 | private $uploadId = 0; |
| 11 | private $parts = array(); |
| 12 | private $storageType = null; |
| 13 | |
| 14 | function __construct() |
| 15 | { |
| 16 | $this->type = SG_STATE_TYPE_UPLOAD; |
| 17 | } |
| 18 | |
| 19 | public function setActiveDirectory($activeDirectory) |
| 20 | { |
| 21 | $this->activeDirectory = $activeDirectory; |
| 22 | } |
| 23 | |
| 24 | public function setCurrentUploadChunksCount($currentUploadChunksCount) |
| 25 | { |
| 26 | $this->currentUploadChunksCount = $currentUploadChunksCount; |
| 27 | } |
| 28 | |
| 29 | public function setTotalUploadChunksCount($totalUploadChunksCount) |
| 30 | { |
| 31 | $this->totalUploadChunksCount = $totalUploadChunksCount; |
| 32 | } |
| 33 | |
| 34 | public function setUploadId($uploadId) |
| 35 | { |
| 36 | $this->uploadId = $uploadId; |
| 37 | } |
| 38 | |
| 39 | public function setParts($parts) |
| 40 | { |
| 41 | $this->parts = $parts; |
| 42 | } |
| 43 | |
| 44 | public function setStorageType($storageType) |
| 45 | { |
| 46 | $this->storageType = $storageType; |
| 47 | } |
| 48 | |
| 49 | public function getStorageType() |
| 50 | { |
| 51 | return $this->storageType; |
| 52 | } |
| 53 | |
| 54 | public function getCurrentUploadChunksCount() |
| 55 | { |
| 56 | return $this->currentUploadChunksCount; |
| 57 | } |
| 58 | |
| 59 | public function getTotalUploadChunksCount() |
| 60 | { |
| 61 | return $this->totalUploadChunksCount; |
| 62 | } |
| 63 | |
| 64 | public function getUploadId() |
| 65 | { |
| 66 | return $this->uploadId; |
| 67 | } |
| 68 | |
| 69 | public function getParts() |
| 70 | { |
| 71 | return $this->parts; |
| 72 | } |
| 73 | |
| 74 | public function getActiveDirectory() |
| 75 | { |
| 76 | return $this->activeDirectory; |
| 77 | } |
| 78 | |
| 79 | public function init($stateJson) |
| 80 | { |
| 81 | $this->type = $stateJson['type']; |
| 82 | $this->parts = $stateJson['parts']; |
| 83 | $this->offset = $stateJson['offset']; |
| 84 | $this->action = $stateJson['action']; |
| 85 | $this->uploadId = $stateJson['uploadId']; |
| 86 | $this->actionId = $stateJson['actionId']; |
| 87 | $this->progress = $stateJson['progress']; |
| 88 | $this->storageType = $stateJson['storageType']; |
| 89 | $this->actionStartTs = $stateJson['actionStartTs']; |
| 90 | $this->warningsFound = $stateJson['warningsFound']; |
| 91 | $this->backupFileName = $stateJson['backupFileName']; |
| 92 | $this->backupFilePath = $stateJson['backupFilePath']; |
| 93 | $this->activeDirectory = $stateJson['activeDirectory']; |
| 94 | $this->pendingStorageUploads = $stateJson['pendingStorageUploads']; |
| 95 | $this->totalUploadChunksCount = $stateJson['totalUploadChunksCount']; |
| 96 | $this->currentUploadChunksCount = $stateJson['currentUploadChunksCount']; |
| 97 | |
| 98 | return $this; |
| 99 | } |
| 100 | |
| 101 | public function save() |
| 102 | { |
| 103 | file_put_contents(SG_BACKUP_DIRECTORY.SG_STATE_FILE_NAME, json_encode(array( |
| 104 | 'type' => $this->type, |
| 105 | 'parts' => $this->parts, |
| 106 | 'token' => $this->token, |
| 107 | 'offset' => $this->offset, |
| 108 | 'action' => $this->action, |
| 109 | 'uploadId' => $this->uploadId, |
| 110 | 'actionId' => $this->actionId, |
| 111 | 'progress' => $this->progress, |
| 112 | 'inprogress' => $this->inprogress, |
| 113 | 'storageType' => $this->storageType, |
| 114 | 'actionStartTs' => $this->actionStartTs, |
| 115 | 'warningsFound' => $this->warningsFound, |
| 116 | 'backupFileName' => $this->backupFileName, |
| 117 | 'backupFilePath' => $this->backupFilePath, |
| 118 | 'activeDirectory' => $this->activeDirectory, |
| 119 | 'pendingStorageUploads' => $this->pendingStorageUploads, |
| 120 | 'totalUploadChunksCount' => $this->totalUploadChunksCount, |
| 121 | 'currentUploadChunksCount' => $this->currentUploadChunksCount |
| 122 | ))); |
| 123 | } |
| 124 | } |
| 125 |