diff options
Diffstat (limited to 'src')
-rw-r--r-- | src/journal-remote/journal-upload.c | 31 |
1 files changed, 31 insertions, 0 deletions
diff --git a/src/journal-remote/journal-upload.c b/src/journal-remote/journal-upload.c index 87d6ff7c06..37c12f0e07 100644 --- a/src/journal-remote/journal-upload.c +++ b/src/journal-remote/journal-upload.c @@ -31,6 +31,7 @@ #include "util.h" #include "build.h" #include "fileio.h" +#include "mkdir.h" #include "conf-parser.h" #include "journal-upload.h" @@ -93,6 +94,32 @@ static size_t output_callback(char *buf, return size * nmemb; } +static int check_cursor_updating(Uploader *u) { + _cleanup_free_ char *temp_path = NULL; + _cleanup_fclose_ FILE *f = NULL; + int r; + + if (!u->state_file) + return 0; + + r = mkdir_parents(u->state_file, 0755); + if (r < 0) { + log_error("Cannot create parent directory of state file %s: %s", + u->state_file, strerror(-r)); + return r; + } + + r = fopen_temporary(u->state_file, &f, &temp_path); + if (r < 0) { + log_error("Cannot save state to %s: %s", + u->state_file, strerror(-r)); + return r; + } + unlink(temp_path); + + return 0; +} + static int update_cursor_state(Uploader *u) { _cleanup_free_ char *temp_path = NULL; _cleanup_fclose_ FILE *f = NULL; @@ -779,6 +806,10 @@ int main(int argc, char **argv) { sd_event_set_watchdog(u.events, true); + r = check_cursor_updating(&u); + if (r < 0) + goto cleanup; + log_debug("%s running as pid "PID_FMT, program_invocation_short_name, getpid()); |