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
9 years ago
SGCharsetHandler.php
7 years ago
SGDBState.php
8 years ago
SGEntry.php
9 years ago
SGFileEntry.php
5 years ago
SGFileState.php
5 years ago
SGMigrateState.php
8 years ago
SGMysqldump.php
5 years ago
SGReloadHandler.php
5 years ago
SGReloader.php
5 years ago
SGReloaderState.php
9 years ago
SGReviewManager.php
6 years ago
SGState.php
5 years ago
SGStatsRequests.php
5 years ago
SGUploadHandler.php
5 years ago
SGUploadState.php
5 years ago
SGFileState.php
195 lines
| 1 | <?php |
| 2 | |
| 3 | require_once(dirname(__FILE__).'/SGState.php'); |
| 4 | |
| 5 | class SGFileState extends SGState |
| 6 | { |
| 7 | private $cdrSize = 0; |
| 8 | private $ranges = array(); |
| 9 | private $fileOffsetInArchive = 0; |
| 10 | private $headerSize = 0; |
| 11 | private $cdr = array(); |
| 12 | private $cursor = 0; |
| 13 | private $rangeCursor = 0; |
| 14 | private $numberOfEntries = 0; |
| 15 | |
| 16 | private $progressCursor = 0; |
| 17 | private $cdrCursor = 0; |
| 18 | private $filesActionStartTs = 0; |
| 19 | |
| 20 | function __construct() |
| 21 | { |
| 22 | $this->type = SG_STATE_TYPE_FILE; |
| 23 | } |
| 24 | |
| 25 | public function setCdrCursor($cdrCursor) |
| 26 | { |
| 27 | $this->cdrCursor = $cdrCursor; |
| 28 | } |
| 29 | |
| 30 | public function getCdrCursor() |
| 31 | { |
| 32 | return $this->cdrCursor; |
| 33 | } |
| 34 | |
| 35 | public function getProgressCursor() |
| 36 | { |
| 37 | return $this->progressCursor; |
| 38 | } |
| 39 | |
| 40 | public function setProgressCursor($progressCursor) |
| 41 | { |
| 42 | $this->progressCursor = $progressCursor; |
| 43 | } |
| 44 | |
| 45 | public function setCursor($cursor) |
| 46 | { |
| 47 | $this->cursor = $cursor; |
| 48 | } |
| 49 | |
| 50 | public function setRangeCursor($rangeCursor) |
| 51 | { |
| 52 | $this->rangeCursor = $rangeCursor; |
| 53 | } |
| 54 | |
| 55 | public function setNumberOfEntries($numberOfEntries) |
| 56 | { |
| 57 | $this->numberOfEntries = $numberOfEntries; |
| 58 | } |
| 59 | |
| 60 | public function getCursor() |
| 61 | { |
| 62 | return $this->cursor; |
| 63 | } |
| 64 | |
| 65 | public function getRangeCursor() |
| 66 | { |
| 67 | return $this->rangeCursor; |
| 68 | } |
| 69 | |
| 70 | public function getNumberOfEntries() |
| 71 | { |
| 72 | return $this->numberOfEntries; |
| 73 | } |
| 74 | |
| 75 | public function setCdr($cdr = array()) |
| 76 | { |
| 77 | $this->cdr = $cdr; |
| 78 | } |
| 79 | |
| 80 | public function getCdr() |
| 81 | { |
| 82 | return $this->cdr; |
| 83 | } |
| 84 | |
| 85 | public function setCdrSize($cdrSize) |
| 86 | { |
| 87 | $this->cdrSize = $cdrSize; |
| 88 | } |
| 89 | |
| 90 | public function setRanges($ranges) |
| 91 | { |
| 92 | $this->ranges = $ranges; |
| 93 | } |
| 94 | |
| 95 | public function setHeaderSize($headerSize) |
| 96 | { |
| 97 | $this->headerSize = $headerSize; |
| 98 | } |
| 99 | |
| 100 | public function getHeaderSize() |
| 101 | { |
| 102 | return $this->headerSize; |
| 103 | } |
| 104 | |
| 105 | public function getRanges() |
| 106 | { |
| 107 | return $this->ranges; |
| 108 | } |
| 109 | |
| 110 | public function getCdrSize() |
| 111 | { |
| 112 | return $this->cdrSize; |
| 113 | } |
| 114 | |
| 115 | public function getFileOffsetInArchive() |
| 116 | { |
| 117 | return $this->fileOffsetInArchive; |
| 118 | } |
| 119 | |
| 120 | public function setFilesActionStartTs($filesActionStartTs) |
| 121 | { |
| 122 | $this->filesActionStartTs = $filesActionStartTs; |
| 123 | } |
| 124 | |
| 125 | public function getFilesActionStartTs() |
| 126 | { |
| 127 | return $this->filesActionStartTs; |
| 128 | } |
| 129 | |
| 130 | public function setFileOffsetInArchive($fileOffsetInArchive) |
| 131 | { |
| 132 | $this->fileOffsetInArchive = $fileOffsetInArchive; |
| 133 | } |
| 134 | |
| 135 | public function init($stateJson) |
| 136 | { |
| 137 | $this->cdrSize = $stateJson['cdrSize']; |
| 138 | $this->ranges = $stateJson['ranges']; |
| 139 | $this->offset = $stateJson['offset']; |
| 140 | $this->headerSize = $stateJson['headerSize']; |
| 141 | $this->inprogress = $stateJson['inprogress']; |
| 142 | $this->cdr = $stateJson['cdr']; |
| 143 | $this->action = $stateJson['action']; |
| 144 | $this->actionId = $stateJson['actionId']; |
| 145 | $this->actionStartTs = $stateJson['actionStartTs']; |
| 146 | $this->backupFileName = $stateJson['backupFileName']; |
| 147 | $this->backupFilePath = $stateJson['backupFilePath']; |
| 148 | $this->progress = $stateJson['progress']; |
| 149 | $this->warningsFound = $stateJson['warningsFound']; |
| 150 | $this->pendingStorageUploads = $stateJson['pendingStorageUploads']; |
| 151 | $this->numberOfEntries = $stateJson['numberOfEntries']; |
| 152 | $this->cursor = $stateJson['cursor']; |
| 153 | $this->rangeCursor = $stateJson['rangeCursor']; |
| 154 | $this->fileOffsetInArchive = $stateJson['fileOffsetInArchive']; |
| 155 | $this->progressCursor = $stateJson['progressCursor']; |
| 156 | $this->cdrCursor = $stateJson['cdrCursor']; |
| 157 | $this->restoreMode = $stateJson['restoreMode']; |
| 158 | $this->restoreFiles = $stateJson['restoreFiles']; |
| 159 | $this->filesActionStartTs = $stateJson['filesActionStartTs']; |
| 160 | |
| 161 | return $this; |
| 162 | } |
| 163 | |
| 164 | public function save() |
| 165 | { |
| 166 | file_put_contents(SG_BACKUP_DIRECTORY.SG_STATE_FILE_NAME, json_encode(array( |
| 167 | 'inprogress' => $this->inprogress, |
| 168 | 'headerSize' => $this->headerSize, |
| 169 | 'offset' => $this->offset, |
| 170 | 'ranges' => $this->ranges, |
| 171 | 'type' => $this->type, |
| 172 | 'token' => $this->token, |
| 173 | 'action' => $this->action, |
| 174 | 'actionId' => $this->actionId, |
| 175 | 'actionStartTs' => $this->actionStartTs, |
| 176 | 'backupFileName' => $this->backupFileName, |
| 177 | 'backupFilePath' => $this->backupFilePath, |
| 178 | 'progress' => $this->progress, |
| 179 | 'warningsFound' => $this->warningsFound, |
| 180 | 'cdrSize' => $this->cdrSize, |
| 181 | 'pendingStorageUploads' => $this->pendingStorageUploads, |
| 182 | 'cdr' => $this->cdr, |
| 183 | 'numberOfEntries' => $this->numberOfEntries, |
| 184 | 'cursor' => $this->cursor, |
| 185 | 'rangeCursor' => $this->rangeCursor, |
| 186 | 'fileOffsetInArchive' => $this->fileOffsetInArchive, |
| 187 | 'progressCursor' => $this->progressCursor, |
| 188 | 'cdrCursor' => $this->cdrCursor, |
| 189 | 'restoreMode' => $this->restoreMode, |
| 190 | 'restoreFiles' => $this->restoreFiles, |
| 191 | 'filesActionStartTs' => $this->filesActionStartTs |
| 192 | ))); |
| 193 | } |
| 194 | } |
| 195 |