From e803aa488c3a95193d3e3ae358b640c299f8f121 Mon Sep 17 00:00:00 2001 From: salmonik Date: Mon, 23 Nov 2026 20:36:22 +0100 Subject: License --- src/session.rs | 15 +++++++++++---- 1 file changed, 11 insertions(+), 4 deletions(-) (limited to 'src/session.rs') diff --git a/src/session.rs b/src/session.rs index 8fc6d29..a75b4c3 100644 --- a/src/session.rs +++ b/src/session.rs @@ -1,3 +1,10 @@ +/* + * This file is part of agent686 + * Copyright (C) 2026 Salmonik + * SPDX-License-Identifier: GPL-3.0-or-later + * https://git.2137697.xyz/agent686 + */ + use std::fs::{File, OpenOptions}; use std::hash::{Hash, Hasher}; use std::io::{BufRead, BufReader, Read, Write}; @@ -54,9 +61,7 @@ fn restrict(path: &Path, mode: u32) { fn lock_exclusive(file: &File, id: &str) -> Result<(), String> { let locked = unsafe { libc::flock(file.as_raw_fd(), libc::LOCK_EX | libc::LOCK_NB) }; if locked != 0 { - return Err(format!( - "session {id} is already open in another process" - )); + return Err(format!("session {id} is already open in another process")); } Ok(()) } @@ -258,7 +263,9 @@ impl Session { pub fn rewrite(&mut self, system: &Value, messages: &[Value]) -> Result<(), String> { use std::io::{Seek, SeekFrom, Write}; self.file.set_len(0).map_err(|e| e.to_string())?; - self.file.seek(SeekFrom::Start(0)).map_err(|e| e.to_string())?; + self.file + .seek(SeekFrom::Start(0)) + .map_err(|e| e.to_string())?; let header = json!({ "t": "header", "session": self.id, -- cgit v1.2.3