Kaynağa Gözat

Fix bug where accessed times were wrong!

It used the mtime, rather than the atime. Copy and paste error. Whoops!
Benjamin Sago 8 yıl önce
ebeveyn
işleme
5bdf6304bb
5 değiştirilmiş dosya ile 16 ekleme ve 1 silme
  1. 2 0
      Vagrantfile
  2. 1 1
      src/fs/file.rs
  3. 4 0
      xtests/dates_accessed
  4. 4 0
      xtests/dates_modified
  5. 5 0
      xtests/run.sh

+ 2 - 0
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
 
 

+ 1 - 1
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'.

+ 4 - 0
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

+ 4 - 0
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

+ 5 - 0
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.