]> arthur.barton.de Git - bup.git/commitdiff
Modify drecurse.py and index.py to use xstat functions.
authorRob Browning <rlb@defaultvalue.org>
Mon, 25 Oct 2010 00:00:53 +0000 (19:00 -0500)
committerRob Browning <rlb@defaultvalue.org>
Mon, 25 Oct 2010 00:00:53 +0000 (19:00 -0500)
lib/bup/drecurse.py
lib/bup/index.py
lib/bup/t/tindex.py

index ac0115e9f1685c965fad86bf883e44a045a72383..129679a2219c5e84f8f1833af6b7ef44a81c05f4 100644 (file)
@@ -1,5 +1,6 @@
 import stat
 from bup.helpers import *
+import bup.xstat as xstat
 
 try:
     O_LARGEFILE = os.O_LARGEFILE
@@ -26,7 +27,7 @@ class OsFile:
         os.fchdir(self.fd)
 
     def stat(self):
-        return os.fstat(self.fd)
+        return xstat.fstat(self.fd)
 
 
 _IFMT = stat.S_IFMT(0xffffffff)  # avoid function call in inner loop
@@ -34,7 +35,7 @@ def _dirlist():
     l = []
     for n in os.listdir('.'):
         try:
-            st = os.lstat(n)
+            st = xstat.lstat(n)
         except OSError, e:
             add_error(Exception('%s: %s' % (realpath(n), str(e))))
             continue
@@ -68,7 +69,7 @@ def recursive_dirlist(paths, xdev):
         assert(type(paths) != type(''))
         for path in paths:
             try:
-                pst = os.lstat(path)
+                pst = xstat.lstat(path)
                 if stat.S_ISLNK(pst.st_mode):
                     yield (path, pst)
                     continue
index 348b73d8ea45a1ce16ff973161a8edd19cd4fcc2..2c53d9eb64def5b7677c643367e50dc2c12b6959 100644 (file)
@@ -95,17 +95,19 @@ class Entry:
     def from_stat(self, st, tstart):
         old = (self.dev, self.ctime, self.mtime,
                self.uid, self.gid, self.size, self.flags & IX_EXISTS)
-        new = (st.st_dev, int(st.st_ctime), int(st.st_mtime),
+        new = (st.st_dev,
+               int(st.st_ctime.approx_secs()),
+               int(st.st_mtime.approx_secs()),
                st.st_uid, st.st_gid, st.st_size, IX_EXISTS)
         self.dev = st.st_dev
-        self.ctime = int(st.st_ctime)
-        self.mtime = int(st.st_mtime)
+        self.ctime = int(st.st_ctime.approx_secs())
+        self.mtime = int(st.st_mtime.approx_secs())
         self.uid = st.st_uid
         self.gid = st.st_gid
         self.size = st.st_size
         self.mode = st.st_mode
         self.flags |= IX_EXISTS
-        if int(st.st_ctime) >= tstart or old != new \
+        if int(st.st_ctime.approx_secs()) >= tstart or old != new \
               or self.sha == EMPTY_SHA or not self.gitmode:
             self.invalidate()
         self._fixup()
@@ -406,8 +408,10 @@ class Writer:
         if st:
             isdir = stat.S_ISDIR(st.st_mode)
             assert(isdir == endswith)
-            e = NewEntry(basename, name, st.st_dev, int(st.st_ctime),
-                         int(st.st_mtime), st.st_uid, st.st_gid,
+            e = NewEntry(basename, name, st.st_dev,
+                         int(st.st_ctime.approx_secs()),
+                         int(st.st_mtime.approx_secs()),
+                         st.st_uid, st.st_gid,
                          st.st_size, st.st_mode, gitmode, sha, flags,
                          0, 0)
         else:
index 1fee408c4c512889b8b66a5471555f0fe22d53d4..e6ba44b6facaa2edd84667ab089c9758a309fc2b 100644 (file)
@@ -1,6 +1,7 @@
 import os
 from bup import index
 from bup.helpers import *
+import bup.xstat as xstat
 from wvtest import *
 
 @wvtest
@@ -17,8 +18,8 @@ def index_basic():
 @wvtest
 def index_writer():
     unlink('index.tmp')
-    ds = os.stat('.')
-    fs = os.stat('tindex.py')
+    ds = xstat.stat('.')
+    fs = xstat.stat('tindex.py')
     w = index.Writer('index.tmp')
     w.add('/var/tmp/sporky', fs)
     w.add('/etc/passwd', fs)
@@ -49,8 +50,8 @@ def eget(l, ename):
 def index_dirty():
     unlink('index.tmp')
     unlink('index2.tmp')
-    ds = os.stat('.')
-    fs = os.stat('tindex.py')
+    ds = xstat.stat('.')
+    fs = xstat.stat('tindex.py')
     
     w1 = index.Writer('index.tmp')
     w1.add('/a/b/x', fs)