aboutsummaryrefslogtreecommitdiff
path: root/lib/dircache.py
diff options
context:
space:
mode:
Diffstat (limited to 'lib/dircache.py')
-rw-r--r--lib/dircache.py40
1 files changed, 20 insertions, 20 deletions
diff --git a/lib/dircache.py b/lib/dircache.py
index c14db3e..b40f76e 100644
--- a/lib/dircache.py
+++ b/lib/dircache.py
@@ -10,27 +10,27 @@ import path
cache = {}
def listdir(path): # List directory contents, using cache
- try:
- cached_mtime, list = cache[path]
- del cache[path]
- except RuntimeError:
- cached_mtime, list = -1, []
- try:
- mtime = posix.stat(path)[8]
- except posix.error:
- return []
- if mtime <> cached_mtime:
- try:
- list = posix.listdir(path)
- except posix.error:
- return []
- list.sort()
- cache[path] = mtime, list
- return list
+ try:
+ cached_mtime, list = cache[path]
+ del cache[path]
+ except RuntimeError:
+ cached_mtime, list = -1, []
+ try:
+ mtime = posix.stat(path)[8]
+ except posix.error:
+ return []
+ if mtime <> cached_mtime:
+ try:
+ list = posix.listdir(path)
+ except posix.error:
+ return []
+ list.sort()
+ cache[path] = mtime, list
+ return list
opendir = listdir # XXX backward compatibility
def annotate(head, list): # Add '/' suffixes to directories
- for i in range(len(list)):
- if path.isdir(path.cat(head, list[i])):
- list[i] = list[i] + '/'
+ for i in range(len(list)):
+ if path.isdir(path.cat(head, list[i])):
+ list[i] = list[i] + '/'