about summary refs log tree commit diff
path: root/src/main.rs
diff options
context:
space:
mode:
Diffstat (limited to 'src/main.rs')
-rw-r--r--src/main.rs12
1 files changed, 12 insertions, 0 deletions
diff --git a/src/main.rs b/src/main.rs
index b8eeb6b9fb..ef28ee8804 100644
--- a/src/main.rs
+++ b/src/main.rs
@@ -494,6 +494,18 @@ fn receiver_loop(mut journal: Journal) -> Result<()> {
 /// is still being written, this will first write the cursor into a
 /// temporary file and then move it.
 fn persist_cursor(cursor: String) -> Result<()> {
+    // This code exists to aid in tracking down if there are other
+    // causes of issue #2 than what has already been taken care of.
+    //
+    // One theory is that journald (or the Rust library to interface
+    // with it) may occasionally return empty cursor strings. If this
+    // is ever the case, we would like to know about it.
+    if cursor.is_empty() {
+        error!("Received empty journald cursor position, refusing to persist!");
+        error!("Please report this message at https://github.com/tazjin/journaldriver/issues/2");
+        return Ok(())
+    }
+
     let mut file = File::create(&*CURSOR_TMP_FILE)?;
     write!(file, "{}", cursor).context("Failed to write cursor file")?;
     rename(&*CURSOR_TMP_FILE, &*CURSOR_FILE)