When indexing a fifo, you can try to open it (for security reasons) but it
has to be O_NDELAY just in case the fifo doesn't have anyone on the other
end; otherwise indexing can freeze.
In index.reduce_paths(), we weren't reporting ENOENT for reasons I can no
longer remember, but I think they must have been wrong. Obviously if
someone specifies a nonexistent path on the command line, we should barf
rather than silently not back it up.
Add some unit tests to catch both cases.
class OsFile:
def __init__(self, path):
self.fd = None
- self.fd = os.open(path, os.O_RDONLY|O_LARGEFILE|os.O_NOFOLLOW)
+ self.fd = os.open(path,
+ os.O_RDONLY|O_LARGEFILE|os.O_NOFOLLOW|os.O_NDELAY)
def __del__(self):
if self.fd:
xpaths = []
for p in paths:
rp = realpath(p)
- try:
- st = os.lstat(rp)
- if stat.S_ISDIR(st.st_mode):
- rp = slashappend(rp)
- p = slashappend(p)
- except OSError, e:
- if e.errno != errno.ENOENT:
- raise
+ st = os.lstat(rp)
+ if stat.S_ISDIR(st.st_mode):
+ rp = slashappend(rp)
+ p = slashappend(p)
xpaths.append((rp, p))
xpaths.sort()
./"
WVPASSEQ "$(cd $D && bup index -s .)" "$(cd $D && bup index -s .)"
+WVFAIL bup save -t $D/doesnt-exist-filename
+
+mv $BUP_DIR/bupindex $BUP_DIR/bi.old
+WVFAIL bup save -t $D/d/e/fifotest
+mkfifo $D/d/e/fifotest
+WVPASS bup index -u $D/d/e/fifotest
+WVFAIL bup save -t $D/d/e/fifotest
+WVFAIL bup save -t $D/d/e
+rm -f $D/d/e/fifotest
+WVPASS bup index -u $D/d/e
+WVFAIL bup save -t $D/d/e/fifotest
+mv $BUP_DIR/bi.old $BUP_DIR/bupindex
+
+WVPASS bup index -u $D/d/e
WVPASS bup save -t $D/d/e
WVPASSEQ "$(cd $D && bup index -m)" \
"f