chiark
/
gitweb
/
~mdw
/
rsync-backup
/ commitdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
| commitdiff |
tree
raw
|
patch
|
inline
| side by side (parent:
8aeb0c5
)
fshash.in: Save and restore working directory when walking.
author
Mark Wooding
<mdw@distorted.org.uk>
Sun, 7 Oct 2012 21:20:04 +0000
(22:20 +0100)
committer
Mark Wooding
<mdw@distorted.org.uk>
Sun, 7 Oct 2012 21:20:04 +0000
(22:20 +0100)
fshash.in
patch
|
blob
|
blame
|
history
diff --git
a/fshash.in
b/fshash.in
index b6aa4cfc5f8ec9bd068943061c0baa56ac3e8b58..4f8b1c76e954811ba2ee13d77ff92e85b16bf285 100644
(file)
--- a/
fshash.in
+++ b/
fshash.in
@@
-98,10
+98,15
@@
def enum_walk(file, func):
dir([OS.path.join(d.name, e) for e in dirents(d.name)], dev)
if file.endswith('/'):
dir([OS.path.join(d.name, e) for e in dirents(d.name)], dev)
if file.endswith('/'):
- OS.chdir(file)
- fi = FileInfo('.')
- func(fi)
- dir(dirents('.'), fi.st.st_dev)
+ cwd = OS.open('.', OS.O_RDONLY)
+ try:
+ OS.chdir(file)
+ fi = FileInfo('.')
+ func(fi)
+ dir(dirents('.'), fi.st.st_dev)
+ finally:
+ OS.fchdir(cwd)
+ OS.close(cwd)
else:
fi = FileInfo(file)
func(fi)
else:
fi = FileInfo(file)
func(fi)