From 080466200060d2d3ec64bec32a4959fa061b79ce Mon Sep 17 00:00:00 2001 From: troido Date: Thu, 23 Apr 2020 12:53:01 +0200 Subject: accept authentication messages, and validate registrations --- src/persistence.rs | 19 +++---------------- 1 file changed, 3 insertions(+), 16 deletions(-) (limited to 'src/persistence.rs') diff --git a/src/persistence.rs b/src/persistence.rs index 1174ceb..2d927ee 100644 --- a/src/persistence.rs +++ b/src/persistence.rs @@ -1,5 +1,5 @@ -use std::path::{PathBuf, Path}; +use std::path::{PathBuf}; use std::fs; use std::env; use std::io::ErrorKind; @@ -12,7 +12,8 @@ use crate::{ playerstate::PlayerState, Timestamp, aerr, - errors::AnyError + errors::AnyError, + util::write_file_safe }; @@ -153,18 +154,4 @@ impl PersistentStorage for FileStorage { } } -fn write_file_safe, C: AsRef<[u8]>>(path: P, contents: C) -> Result<(), AnyError> { - let temppath = path - .as_ref() - .with_file_name( - format!( - "tempfile_{}_{}.tmp", - path.as_ref().file_name().ok_or(aerr!("writing to directory"))?.to_str().unwrap_or("invalid"), - rand::random::() - ) - ); - fs::write(&temppath, contents)?; - fs::rename(&temppath, path)?; - Ok(()) -} -- cgit