summaryrefslogtreecommitdiff
path: root/subplotlib/src/steplibrary/files.rs
diff options
context:
space:
mode:
Diffstat (limited to 'subplotlib/src/steplibrary/files.rs')
-rw-r--r--subplotlib/src/steplibrary/files.rs10
1 files changed, 6 insertions, 4 deletions
diff --git a/subplotlib/src/steplibrary/files.rs b/subplotlib/src/steplibrary/files.rs
index 8abe546..b1596ae 100644
--- a/subplotlib/src/steplibrary/files.rs
+++ b/subplotlib/src/steplibrary/files.rs
@@ -90,7 +90,7 @@ pub fn touch_with_timestamp(context: &Datadir, filename: &Path, mtime: &str) {
let fd = format_description!(
"[year]-[month]-[day] [hour]:[minute]:[second] [offset_hour]:[offset_minute]"
);
- let full_time = format!("{} +00:00", mtime);
+ let full_time = format!("{mtime} +00:00");
let ts = OffsetDateTime::parse(&full_time, &fd)?;
let (secs, nanos) = (ts.unix_timestamp(), 0);
let mtime = FileTime::from_unix_time(secs, nanos);
@@ -99,6 +99,7 @@ pub fn touch_with_timestamp(context: &Datadir, filename: &Path, mtime: &str) {
drop(
OpenOptions::new()
.create(true)
+ .truncate(false)
.write(true)
.open(&full_path)?,
);
@@ -130,7 +131,7 @@ pub fn remember_metadata(context: &ScenarioContext, filename: &Path) {
|context: &Datadir| context.canonicalise_filename(filename),
false,
)?;
- let metadata = fs::metadata(&full_path)?;
+ let metadata = fs::metadata(full_path)?;
context.with_mut(
|context: &mut Files| {
context.metadata.insert(filename.to_owned(), metadata);
@@ -154,6 +155,7 @@ pub fn touch(context: &Datadir, filename: &Path) {
drop(
OpenOptions::new()
.create(true)
+ .truncate(false)
.write(true)
.open(&full_path)?,
);
@@ -320,7 +322,7 @@ pub fn has_remembered_metadata(context: &ScenarioContext, filename: &Path) {
|context: &Datadir| context.canonicalise_filename(filename),
false,
)?;
- let metadata = fs::metadata(&full_path)?;
+ let metadata = fs::metadata(full_path)?;
if let Some(remembered) = context.with(
|context: &Files| Ok(context.metadata.get(filename).cloned()),
false,
@@ -359,7 +361,7 @@ pub fn has_different_metadata(context: &ScenarioContext, filename: &Path) {
|context: &Datadir| context.canonicalise_filename(filename),
false,
)?;
- let metadata = fs::metadata(&full_path)?;
+ let metadata = fs::metadata(full_path)?;
if let Some(remembered) = context.with(
|context: &Files| Ok(context.metadata.get(filename).cloned()),
false,