Skip to content
This repository has been archived by the owner on Oct 17, 2021. It is now read-only.

Commit

Permalink
Use the full path rather than filename only in logging cache
Browse files Browse the repository at this point in the history
Apparently there are some circumstances on Linux where the cache is not
cleared between rounds. Although it would be good to ensure the cache is
cleared, at a minimum there's no reason for rust-g not to support
writing to both "one/foo.txt" and "two/foo.txt" in the same session.
  • Loading branch information
SpaceManiac committed Jun 15, 2020
1 parent 6ba75cd commit 0cee19e
Showing 1 changed file with 2 additions and 9 deletions.
11 changes: 2 additions & 9 deletions src/log.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
use crate::error::{Error, Result};
use crate::error::Result;
use chrono::Utc;
use std::{
cell::RefCell,
Expand All @@ -19,7 +19,7 @@ byond_fn! { log_write(path, data, ...rest) {
// open file
let mut map = cell.borrow_mut();
let path = Path::new(&path as &str);
let file = match map.entry(filename(path)?) {
let file = match map.entry(path.into()) {
Entry::Occupied(elem) => elem.into_mut(),
Entry::Vacant(elem) => elem.insert(open(path)?),
};
Expand Down Expand Up @@ -52,13 +52,6 @@ byond_fn! { log_close_all() {
Some("")
} }

fn filename(path: &Path) -> Result<OsString> {
match path.file_name() {
Some(filename) => Ok(filename.to_os_string()),
None => Err(Error::InvalidFilename),
}
}

fn open(path: &Path) -> Result<File> {
if let Some(parent) = path.parent() {
fs::create_dir_all(parent)?
Expand Down

0 comments on commit 0cee19e

Please sign in to comment.