37
37
use ArtificialOwl \MySmallPhpTools \Traits \Nextcloud \nc23 \TNC23Deserialize ;
38
38
use ArtificialOwl \MySmallPhpTools \Traits \Nextcloud \nc23 \TNC23Logger ;
39
39
use OCA \Backup \AppInfo \Application ;
40
+ use OCA \Backup \Exceptions \RestoringChunkNotFoundException ;
40
41
use OCA \Backup \Exceptions \RestoringPointNotFoundException ;
42
+ use OCA \Backup \Exceptions \RestoringPointNotInitiatedException ;
41
43
use OCA \Backup \IRemoteRequest ;
42
- use OCA \Backup \Model \RestoringChunk ;
44
+ use OCA \Backup \Model \RestoringChunkPart ;
43
45
use OCA \Backup \Service \ChunkService ;
46
+ use OCA \Backup \Service \PackService ;
44
47
use OCA \Backup \Service \PointService ;
45
48
use OCP \Files \NotFoundException ;
46
49
use OCP \Files \NotPermittedException ;
@@ -64,6 +67,9 @@ class DownloadRestoringChunk extends CoreRequest implements IRemoteRequest {
64
67
/** @var ChunkService */
65
68
private $ chunkService ;
66
69
70
+ /** @var PackService */
71
+ private $ packService ;
72
+
67
73
68
74
/**
69
75
* DownloadRestoringChunk constructor.
@@ -73,33 +79,40 @@ class DownloadRestoringChunk extends CoreRequest implements IRemoteRequest {
73
79
*/
74
80
public function __construct (
75
81
PointService $ pointService ,
76
- ChunkService $ chunkService
82
+ ChunkService $ chunkService ,
83
+ PackService $ packService
77
84
) {
78
85
parent ::__construct ();
79
86
80
87
$ this ->pointService = $ pointService ;
81
88
$ this ->chunkService = $ chunkService ;
89
+ $ this ->packService = $ packService ;
82
90
83
91
$ this ->setup ('app ' , Application::APP_ID );
84
92
}
85
93
86
94
87
95
/**
96
+ * @throws RestoringPointNotInitiatedException
97
+ * @throws RestoringChunkNotFoundException
88
98
*/
89
99
public function execute (): void {
90
100
try {
91
101
$ signedRequest = $ this ->getSignedRequest ();
92
102
$ signatory = $ signedRequest ->getSignatory ();
93
103
$ pointId = $ signedRequest ->getIncomingRequest ()->getParam ('pointId ' );
104
+ $ chunkName = $ signedRequest ->getIncomingRequest ()->getParam ('chunkName ' );
94
105
95
106
$ point = $ this ->pointService ->getRestoringPoint ($ pointId , $ signatory ->getInstance ());
96
- /** @var RestoringChunk $chunk */
97
- $ chunk = $ this ->deserializeJson ($ signedRequest ->getBody (), RestoringChunk::class);
107
+ $ chunk = $ this ->chunkService ->getChunkFromRP ($ point , $ chunkName );
108
+
109
+ /** @var RestoringChunkPart $part */
110
+ $ part = $ this ->deserializeJson ($ signedRequest ->getBody (), RestoringChunkPart::class);
98
111
99
112
$ this ->pointService ->initBaseFolder ($ point );
100
- $ this ->chunkService -> getChunkContent ($ point , $ chunk );
113
+ $ this ->packService -> getChunkPartContent ($ point , $ chunk, $ part );
101
114
102
- $ this ->setOutcome ($ this ->serialize ($ chunk ));
115
+ $ this ->setOutcome ($ this ->serialize ($ part ));
103
116
104
117
} catch (RestoringPointNotFoundException
105
118
| InvalidItemException
0 commit comments