@@ -96,11 +96,20 @@ public CreateBuild createBuild(@RequestHeader(HttpHeaders.AUTHORIZATION) String
96
96
version = versionRepository .save (new Version (project , body .version ));
97
97
}
98
98
99
- Build build = buildRepository .save (new Build (version , body .build , body .result , body .timestamp , body .duration ));
99
+ int ready = 0 ;
100
+ if (body .result != Build .BuildResult .SUCCESS ) {
101
+ ready = 1 ;
102
+ }
103
+
104
+ Build build = buildRepository .save (new Build (version , body .build , body .result , body .timestamp , body .duration , ready ));
100
105
if (body .commits != null ) {
101
106
commitRepository .saveAll (body .commits .stream ().map (commit -> new Commit (build , commit .author , commit .email , commit .description , commit .hash , commit .timestamp )).toList ());
102
107
}
103
108
109
+ if (ready == 1 ) {
110
+ return new CreateBuild (null );
111
+ }
112
+
104
113
CreationState id = creationStateRepository .save (new CreationState (build , body .fileExtension ));
105
114
return new CreateBuild (id .getId ().toString ());
106
115
}
@@ -134,10 +143,6 @@ public ResponseEntity<String> uploadFile(@RequestHeader(HttpHeaders.AUTHORIZATIO
134
143
throw new FileUploadError ();
135
144
}
136
145
137
- Build build = state .getBuild ();
138
- build .setHash (DigestUtils .md5DigestAsHex (bytes ));
139
- buildRepository .save (build );
140
-
141
146
String contentType ;
142
147
try {
143
148
Path tempFile = Files .createTempFile ("papyrus" , state .getId ().toString ());
@@ -148,6 +153,8 @@ public ResponseEntity<String> uploadFile(@RequestHeader(HttpHeaders.AUTHORIZATIO
148
153
throw new FileUploadError ();
149
154
}
150
155
156
+ Build build = state .getBuild ();
157
+
151
158
File file = fileRepository .save (new File (build , contentType , state .getFileExtension ()));
152
159
try {
153
160
Path path = Path .of (configuration .getFileStorage (), file .getId ().toString ());
@@ -156,6 +163,10 @@ public ResponseEntity<String> uploadFile(@RequestHeader(HttpHeaders.AUTHORIZATIO
156
163
throw new FileUploadError ();
157
164
}
158
165
166
+ build .setHash (DigestUtils .md5DigestAsHex (bytes ));
167
+ build .setReady (1 );
168
+ buildRepository .save (build );
169
+
159
170
creationStateRepository .delete (state );
160
171
return ResponseEntity .ok ("" );
161
172
}
0 commit comments