diff options
-rwxr-xr-x | dupfiles | 15 |
1 files changed, 9 insertions, 6 deletions
@@ -20,6 +20,7 @@ import hashlib import optparse import os +import stat import sys import time @@ -56,14 +57,16 @@ class DuplicateFileFinder(object): for dirname, subdirs, filenames in os.walk(root): self.progress.write(dirname) subdirs.sort() + filenames.sort() pathnames = [os.path.join(dirname, f) for f in filenames] for pathname in pathnames: - stat = os.lstat(pathname) - t = (stat.st_dev, stat.st_ino, pathname) - if stat.st_size in self.by_size: - self.by_size[stat.st_size].append(t) - else: - self.by_size[stat.st_size] = [t] + st = os.lstat(pathname) + if stat.S_ISREG(st.st_mode): + t = (st.st_dev, st.st_ino, pathname) + if st.st_size in self.by_size: + self.by_size[st.st_size].append(t) + else: + self.by_size[st.st_size] = [t] self.progress.finished() def duplicates(self): |