BackupGuard
5 years ago
Dropbox
5 years ago
Request
5 years ago
SGArchive.php
5 years ago
SGAuthClient.php
5 years ago
SGCallback.php
5 years ago
SGCdrEntry.php
5 years ago
SGCharsetHandler.php
5 years ago
SGDBState.php
5 years ago
SGEntry.php
5 years ago
SGFileEntry.php
5 years ago
SGFileState.php
5 years ago
SGMigrateState.php
5 years ago
SGMysqldump.php
5 years ago
SGReloadHandler.php
5 years ago
SGReloader.php
5 years ago
SGReloaderState.php
5 years ago
SGReviewManager.php
5 years ago
SGState.php
5 years ago
SGStatsRequests.php
5 years ago
SGUploadHandler.php
5 years ago
SGUploadState.php
5 years ago
SGUploadState.php
152 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 | private $backupId = null; |
| 14 | private $profileId = null; |
| 15 | |
| 16 | function __construct() |
| 17 | { |
| 18 | $this->type = SG_STATE_TYPE_UPLOAD; |
| 19 | } |
| 20 | |
| 21 | public function setBackupId($backupId) |
| 22 | { |
| 23 | $this->backupId = $backupId; |
| 24 | } |
| 25 | |
| 26 | public function getBackupId() |
| 27 | { |
| 28 | return $this->backupId; |
| 29 | } |
| 30 | |
| 31 | public function setProfileId($profileId) |
| 32 | { |
| 33 | $this->profileId = $profileId; |
| 34 | } |
| 35 | |
| 36 | public function getProfileId() |
| 37 | { |
| 38 | return $this->profileId; |
| 39 | } |
| 40 | |
| 41 | public function setActiveDirectory($activeDirectory) |
| 42 | { |
| 43 | $this->activeDirectory = $activeDirectory; |
| 44 | } |
| 45 | |
| 46 | public function setCurrentUploadChunksCount($currentUploadChunksCount) |
| 47 | { |
| 48 | $this->currentUploadChunksCount = $currentUploadChunksCount; |
| 49 | } |
| 50 | |
| 51 | public function setTotalUploadChunksCount($totalUploadChunksCount) |
| 52 | { |
| 53 | $this->totalUploadChunksCount = $totalUploadChunksCount; |
| 54 | } |
| 55 | |
| 56 | public function setUploadId($uploadId) |
| 57 | { |
| 58 | $this->uploadId = $uploadId; |
| 59 | } |
| 60 | |
| 61 | public function setParts($parts) |
| 62 | { |
| 63 | $this->parts = $parts; |
| 64 | } |
| 65 | |
| 66 | public function setStorageType($storageType) |
| 67 | { |
| 68 | $this->storageType = $storageType; |
| 69 | } |
| 70 | |
| 71 | public function getStorageType() |
| 72 | { |
| 73 | return $this->storageType; |
| 74 | } |
| 75 | |
| 76 | public function getCurrentUploadChunksCount() |
| 77 | { |
| 78 | return $this->currentUploadChunksCount; |
| 79 | } |
| 80 | |
| 81 | public function getTotalUploadChunksCount() |
| 82 | { |
| 83 | return $this->totalUploadChunksCount; |
| 84 | } |
| 85 | |
| 86 | public function getUploadId() |
| 87 | { |
| 88 | return $this->uploadId; |
| 89 | } |
| 90 | |
| 91 | public function getParts() |
| 92 | { |
| 93 | return $this->parts; |
| 94 | } |
| 95 | |
| 96 | public function getActiveDirectory() |
| 97 | { |
| 98 | return $this->activeDirectory; |
| 99 | } |
| 100 | |
| 101 | public function init($stateJson) |
| 102 | { |
| 103 | $this->type = $stateJson['type']; |
| 104 | $this->parts = $stateJson['parts']; |
| 105 | $this->offset = $stateJson['offset']; |
| 106 | $this->action = $stateJson['action']; |
| 107 | $this->uploadId = $stateJson['uploadId']; |
| 108 | $this->actionId = $stateJson['actionId']; |
| 109 | $this->progress = $stateJson['progress']; |
| 110 | $this->backupId = $stateJson['backupId']; |
| 111 | $this->profileId = $stateJson['profileId']; |
| 112 | $this->inprogress = $stateJson['inprogress']; |
| 113 | $this->storageType = $stateJson['storageType']; |
| 114 | $this->actionStartTs = $stateJson['actionStartTs']; |
| 115 | $this->warningsFound = $stateJson['warningsFound']; |
| 116 | $this->backupFileName = $stateJson['backupFileName']; |
| 117 | $this->backupFilePath = $stateJson['backupFilePath']; |
| 118 | $this->activeDirectory = $stateJson['activeDirectory']; |
| 119 | $this->pendingStorageUploads = $stateJson['pendingStorageUploads']; |
| 120 | $this->totalUploadChunksCount = $stateJson['totalUploadChunksCount']; |
| 121 | $this->currentUploadChunksCount = $stateJson['currentUploadChunksCount']; |
| 122 | |
| 123 | return $this; |
| 124 | } |
| 125 | |
| 126 | public function save() |
| 127 | { |
| 128 | file_put_contents(SG_BACKUP_DIRECTORY.SG_STATE_FILE_NAME, json_encode(array( |
| 129 | 'type' => $this->type, |
| 130 | 'parts' => $this->parts, |
| 131 | 'token' => $this->token, |
| 132 | 'offset' => $this->offset, |
| 133 | 'action' => $this->action, |
| 134 | 'uploadId' => $this->uploadId, |
| 135 | 'actionId' => $this->actionId, |
| 136 | 'progress' => $this->progress, |
| 137 | 'backupId' => $this->backupId, |
| 138 | 'profileId' => $this->profileId, |
| 139 | 'inprogress' => $this->inprogress, |
| 140 | 'storageType' => $this->storageType, |
| 141 | 'actionStartTs' => $this->actionStartTs, |
| 142 | 'warningsFound' => $this->warningsFound, |
| 143 | 'backupFileName' => $this->backupFileName, |
| 144 | 'backupFilePath' => $this->backupFilePath, |
| 145 | 'activeDirectory' => $this->activeDirectory, |
| 146 | 'pendingStorageUploads' => $this->pendingStorageUploads, |
| 147 | 'totalUploadChunksCount' => $this->totalUploadChunksCount, |
| 148 | 'currentUploadChunksCount' => $this->currentUploadChunksCount |
| 149 | ))); |
| 150 | } |
| 151 | } |
| 152 |