return r;
}
+static int pakfire_job_upload_packages(struct pakfire_job* self) {
+ return 0; // XXX TODO
+}
+
+/*
+ Called when the log file has been uploaded...
+*/
+static int pakfire_job_logfile_uploaded(struct pakfire_client* client,
+ pakfire_client_upload_status status, const char* path, const char* uuid, void* data) {
+ struct pakfire_job* self = data;
+
+ // Check the status
+ switch (status) {
+ case PAKFIRE_CLIENT_UPLOAD_SUCCESSFUL:
+ // Free any previous upload IDs
+ if (self->uploads.logfile)
+ free(self->uploads.logfile);
+
+ // Store the UUID of the upload
+ self->uploads.logfile = strdup(uuid);
+ if (self->uploads.logfile)
+ ERROR(self->ctx, "Failed to store the log file UUID: %m\n");
+ break;
+
+ // Log an error if we could not upload the log file
+ default:
+ ERROR(self->ctx, "Failed to upload the log file: %s\n", strerror(status));
+ break;
+ }
+
+ // Continue with uploading the packages
+ return pakfire_job_upload_packages(self);
+}
+
/*
Called when the job has finished with status as the error code.
*/
-static int pakfire_job_finished(struct pakfire_job* job, int status) {
+static int pakfire_job_finished(struct pakfire_job* job, const siginfo_t* si) {
struct pakfire_xfer* xfer = NULL;
const char* filename = NULL;
const char* path = NULL;
- char* logfile = NULL;
int r;
- DEBUG(job->ctx, "Job %s has finished with status %d\n", job->id, status);
-
// Close the log file
r = pakfire_log_file_close(job->log.file);
if (r < 0) {
goto ERROR;
}
-#if 0
// Upload the log file
- r = pakfire_client_upload(job->client, path, filename, &logfile);
+ r = pakfire_client_upload(job->client, path, filename, pakfire_job_logfile_uploaded, job);
if (r < 0) {
ERROR(job->ctx, "Could not upload the log file: %s\n", strerror(-r));
goto ERROR;
}
-#endif
+#if 0
// Create a new xfer
r = pakfire_job_xfer_create(&xfer, job, "/api/v1/jobs/%s/finished", job->id);
if (r < 0)
r = pakfire_xfer_run_api_request(xfer, NULL, NULL);
if (r < 0)
goto ERROR;
+#endif
// Let the builder know this is finished
r = pakfire_builder_job_finished(job->builder, job);
}
// Signal that the job has finished
- return pakfire_job_finished(job, si->si_status);
+ return pakfire_job_finished(job, si);
}
static int pakfire_job_send_log(struct pakfire_job* job, int priority, const char* line, size_t length) {