static int pakfire_job_finished(struct pakfire_job* job, int status) {
struct pakfire_xfer* xfer = NULL;
char job_id[UUID_STR_LEN];
+ const char* filename = NULL;
const char* path = NULL;
char* logfile = NULL;
int r;
}
}
+ // Fetch the filename of the log file
+ filename = pakfire_log_file_filename(job->log.file);
+ if (!filename) {
+ ERROR(job->ctx, "Log file has no filename\n");
+ r = -EINVAL;
+ goto ERROR;
+ }
+
// Fetch the path of the log file
path = pakfire_log_file_path(job->log.file);
if (!path) {
}
// Upload the log file
- r = pakfire_buildservice_upload(job->service, path, NULL, &logfile);
+ r = pakfire_buildservice_upload(job->service, path, filename, &logfile);
if (r < 0) {
ERROR(job->ctx, "Could not upload the log file: %s\n", strerror(-r));
goto ERROR;
pakfire_ctx_set_log_callback(ctx, pakfire_job_log, job);
// Open a new log file
- r = pakfire_log_file_create(&job->log.file, ctx, PAKFIRE_LOG_FILE_COMPRESS);
+ r = pakfire_log_file_create(&job->log.file, ctx, job_id, PAKFIRE_LOG_FILE_COMPRESS);
if (r < 0) {
ERROR(ctx, "Could not open log file: %s\n", strerror(-r));
goto ERROR;
struct pakfire_ctx* ctx;
int nrefs;
+ // Filename
+ char filename[PATH_MAX];
+
// Flags
int flags;
free(self);
}
-int pakfire_log_file_create(struct pakfire_log_file** file, struct pakfire_ctx* ctx, int flags) {
+int pakfire_log_file_create(struct pakfire_log_file** file, struct pakfire_ctx* ctx,
+ const char* filename, int flags) {
struct pakfire_log_file* self = NULL;
int r;
// Store flags
self->flags = flags;
+ // Store the filename
+ r = pakfire_string_set(self->filename, filename);
+ if (r < 0)
+ goto ERROR;
+
// Make some path
r = pakfire_string_set(self->path, PAKFIRE_TMP_DIR "/pakfire-log.XXXXXX");
if (r < 0)
r = -errno;
goto ERROR;
}
+
+ // Add a suffix to the filename
+ r = pakfire_string_append(self->filename, ".zst");
+ if (r < 0)
+ goto ERROR;
}
- DEBUG(self->ctx, "Created log file %s\n", self->path);
+ DEBUG(self->ctx, "Created log file %s (%s)\n", self->filename, self->path);
// Return the pointer
*file = self;
return NULL;
}
+const char* pakfire_log_file_filename(struct pakfire_log_file* self) {
+ return self->filename;
+}
+
const char* pakfire_log_file_path(struct pakfire_log_file* self) {
return self->path;
}
};
int pakfire_log_file_create(struct pakfire_log_file** file,
- struct pakfire_ctx* ctx, int flags);
+ struct pakfire_ctx* ctx, const char* filename, int flags);
struct pakfire_log_file* pakfire_log_file_ref(struct pakfire_log_file* self);
struct pakfire_log_file* pakfire_log_file_unref(struct pakfire_log_file* self);
+const char* pakfire_log_file_filename(struct pakfire_log_file* self);
const char* pakfire_log_file_path(struct pakfire_log_file* self);
int pakfire_log_file_close(struct pakfire_log_file* self);
int r = EXIT_FAILURE;
// Create a new log file
- ASSERT_SUCCESS(pakfire_log_file_create(&file, t->ctx, flags));
+ ASSERT_SUCCESS(pakfire_log_file_create(&file, t->ctx, "test.log", flags));
// Store a copy of the path
ASSERT_SUCCESS(pakfire_string_set(path, pakfire_log_file_path(file)));