| Conditions | 6 |
| Paths | 6 |
| Total Lines | 21 |
| Code Lines | 14 |
| Lines | 0 |
| Ratio | 0 % |
| Changes | 0 | ||
| 1 | <?php |
||
| 24 | private function restoreFromBackup($bucket, $backupDir) |
||
| 25 | { |
||
| 26 | foreach (new \DirectoryIterator($backupDir) as $file) { |
||
| 27 | if (!$file->isDot() && $file->isFile()) { |
||
| 28 | $keyParts = explode('.', $file->getFilename()); |
||
| 29 | $key = $keyParts[0]; |
||
| 30 | $handle = $file->openFile('r'); |
||
| 31 | $contents = ''; |
||
| 32 | while (!$handle->eof()) { |
||
| 33 | $contents .= $handle->fread(128); |
||
| 34 | } |
||
| 35 | if ($contents != '') { |
||
| 36 | $unserialized = unserialize($contents); |
||
| 37 | $unserialized['content'] = gzuncompress($unserialized['content']); |
||
| 38 | $bucket->store($key, $unserialized['content'], $unserialized['created_time']); |
||
| 39 | } |
||
| 40 | unlink($file->getPathname()); |
||
| 41 | } |
||
| 42 | } |
||
| 43 | |||
| 44 | return $bucket; |
||
| 45 | } |
||
| 47 |