31
31
32
32
namespace OCA \Backup \Service ;
33
33
34
+ use ArtificialOwl \MySmallPhpTools \Traits \Nextcloud \nc23 \TNC23Deserialize ;
34
35
use ArtificialOwl \MySmallPhpTools \Traits \TArrayTools ;
35
36
use ArtificialOwl \MySmallPhpTools \Traits \TFileTools ;
36
37
use ArtificialOwl \MySmallPhpTools \Traits \TStringTools ;
@@ -65,6 +66,7 @@ class ChunkService {
65
66
use TArrayTools;
66
67
use TStringTools;
67
68
use TFileTools;
69
+ use TNC23Deserialize;
68
70
69
71
70
72
public const BACKUP_SCRIPT = 'restore.php ' ;
@@ -181,7 +183,7 @@ public function restoreChunk(
181
183
$ zip ->extractTo ($ root , ($ filename === '' ) ? null : $ filename );
182
184
$ this ->closeZipArchive ($ zip );
183
185
184
- unlink ($ root . self ::PREFIX . $ chunk ->getName () . ' .json ' );
186
+ unlink ($ root . self ::PREFIX . $ chunk ->getName ());
185
187
// $this->restoreFromArchive($archive, $root);
186
188
// $this->deleteArchive($backup, $archive, 'zip');
187
189
}
@@ -259,19 +261,20 @@ public function listFilesFromChunk(RestoringPoint $point, RestoringChunk $chunk)
259
261
260
262
261
263
/**
262
- * @param RestoringChunk $archive
264
+ * @param RestoringChunk $chunk
263
265
* @param ZipArchive $zip
264
266
*/
265
- public function listFilesFromZip (RestoringChunk $ archive , ZipArchive $ zip ): void {
266
- $ json = $ zip ->getFromName (self ::PREFIX . $ archive ->getName () . ' .json ' );
267
+ public function listFilesFromZip (RestoringChunk $ chunk , ZipArchive $ zip ): void {
268
+ $ json = $ zip ->getFromName (self ::PREFIX . $ chunk ->getName ());
267
269
if (!$ json ) {
268
270
return ;
269
271
}
270
272
271
273
$ data = json_decode ($ json , true );
272
- $ files = $ this ->getList ('files ' , $ data , [ArchiveFile::class, 'import ' ], []);
274
+ /** @var ArchiveFile[] $files */
275
+ $ files = $ this ->deserializeArray ($ this ->getArray ('files ' , $ data ), ArchiveFile::class);
273
276
274
- $ archive ->setFiles ($ files );
277
+ $ chunk ->setFiles ($ files );
275
278
}
276
279
277
280
@@ -494,7 +497,7 @@ public function generateZip(RestoringPoint $point, RestoringChunk $chunk): ZipSt
494
497
public function finalizeZip (ZipStreamer $ zip , RestoringChunk $ archive ): void {
495
498
$ str = json_encode ($ archive ->getResume (), JSON_PRETTY_PRINT );
496
499
$ read = fopen ('data://text/plain, ' . $ str , 'rb ' );
497
- $ zip ->addFileFromStream ($ read , self ::PREFIX . $ archive ->getName () . ' .json ' );
500
+ $ zip ->addFileFromStream ($ read , self ::PREFIX . $ archive ->getName ());
498
501
499
502
$ zip ->finalize ();
500
503
}
@@ -509,7 +512,7 @@ private function finalizeChunk(RestoringPoint $point, RestoringChunk $chunk) {
509
512
$ folder = $ this ->getChunkFolder ($ point , $ chunk );
510
513
if ($ this ->configService ->getAppValueBool (ConfigService::PACK_INDEX )) {
511
514
$ folder ->newFile (
512
- self ::PREFIX . $ chunk ->getName () . ' .json ' ,
515
+ self ::PREFIX . $ chunk ->getName (),
513
516
json_encode ($ chunk ->getResume (), JSON_PRETTY_PRINT )
514
517
);
515
518
}
@@ -838,7 +841,7 @@ public function getChunkResource(RestoringPoint $point, RestoringChunk $chunk):
838
841
* @throws NotFoundException
839
842
* @throws NotPermittedException
840
843
*/
841
- public function searchFileInChunk (RestoringPoint $ point , RestoringChunk $ chunk , string $ search ): array {
844
+ public function searchFilesInChunk (RestoringPoint $ point , RestoringChunk $ chunk , string $ search ): array {
842
845
if (empty ($ chunk ->getFiles ())) {
843
846
$ this ->listFilesFromChunk ($ point , $ chunk );
844
847
}
0 commit comments