From 5bdf6304bb9e4bc55e510594f8bbe2c0fe96c9d2 Mon Sep 17 00:00:00 2001 From: Benjamin Sago Date: Wed, 5 Jul 2017 22:07:03 +0100 Subject: [PATCH] Fix bug where accessed times were wrong! It used the mtime, rather than the atime. Copy and paste error. Whoops! --- Vagrantfile | 2 ++ src/fs/file.rs | 2 +- xtests/dates_accessed | 4 ++++ xtests/dates_modified | 4 ++++ xtests/run.sh | 5 +++++ 5 files changed, 16 insertions(+), 1 deletion(-) create mode 100644 xtests/dates_accessed create mode 100644 xtests/dates_modified diff --git a/Vagrantfile b/Vagrantfile index 10c2e79..999ed95 100644 --- a/Vagrantfile +++ b/Vagrantfile @@ -320,6 +320,8 @@ Vagrant.configure(2) do |config| touch -t #{old} -a "#{test_dir}/dates/plum" touch -t #{med} -a "#{test_dir}/dates/pear" touch -t #{new} -a "#{test_dir}/dates/peach" + + sudo chown #{user}:#{user} -R "#{test_dir}/dates" EOF diff --git a/src/fs/file.rs b/src/fs/file.rs index 3defdd7..6e99ca7 100644 --- a/src/fs/file.rs +++ b/src/fs/file.rs @@ -282,7 +282,7 @@ impl<'dir> File<'dir> { } pub fn accessed_time(&self) -> f::Time { - f::Time(self.metadata.mtime()) + f::Time(self.metadata.atime()) } /// This file's 'type'. diff --git a/xtests/dates_accessed b/xtests/dates_accessed new file mode 100644 index 0000000..3d80658 --- /dev/null +++ b/xtests/dates_accessed @@ -0,0 +1,4 @@ +Permissions Size User Date Accessed Name +.rw-rw-r-- 0 cassowary  3 Mar 2003 plum +.rw-rw-r-- 0 cassowary 15 Jun 2006 pear +.rw-rw-r-- 0 cassowary 22 Jul 2009 peach diff --git a/xtests/dates_modified b/xtests/dates_modified new file mode 100644 index 0000000..166b68f --- /dev/null +++ b/xtests/dates_modified @@ -0,0 +1,4 @@ +Permissions Size User Date Modified Name +.rw-rw-r-- 0 cassowary  3 Mar 2003 pear +.rw-rw-r-- 0 cassowary 15 Jun 2006 peach +.rw-rw-r-- 0 cassowary 22 Jul 2009 plum diff --git a/xtests/run.sh b/xtests/run.sh index 8493f97..42200e0 100755 --- a/xtests/run.sh +++ b/xtests/run.sh @@ -107,6 +107,11 @@ $exa $testcases/file-names-exts/music.* -I "*.OGG" -1 2>&1 | diff -q - $re $exa $testcases/file-names-exts/music.* -I "*.OGG|*.mp3" -1 2>&1 | diff -q - $results/empty || exit 1 +# Dates and times +$exa $testcases/dates -lh --accessed --sort=accessed 2>&1 | diff -q - $results/dates_accessed || exit 1 +$exa $testcases/dates -lh --sort=modified 2>&1 | diff -q - $results/dates_modified || exit 1 + + # Paths and directories # These directories are created in the VM user’s home directory (the default # location) when a Cargo build is done.