Skip to content

Commit

Permalink
fix possible error if stat call denied access
Browse files Browse the repository at this point in the history
  • Loading branch information
DoTheEvo committed Feb 21, 2016
1 parent 3ab4643 commit fdec88e
Showing 1 changed file with 14 additions and 5 deletions.
19 changes: 14 additions & 5 deletions angrysearch.py
Original file line number Diff line number Diff line change
Expand Up @@ -146,15 +146,24 @@ def error(err):
for dname in dirs:
path = os.path.join(root, dname)
utf_path = path.decode(encoding='utf-8', errors='ignore')
stats = os.lstat(path)
epoch_time = stats.st_mtime.__trunc__()
try:
stats = os.lstat(path)
epoch_time = stats.st_mtime.__trunc__()
except:
print('Cant access: ' + str(path))
epoch_time = 0
dir_list.append(('1', utf_path, '', epoch_time))
for fname in files:
path = os.path.join(root, fname)
utf_path = path.decode(encoding='utf-8', errors='ignore')
stats = os.lstat(path)
size = stats.st_size
epoch_time = stats.st_mtime.__trunc__()
try:
stats = os.lstat(path)
size = stats.st_size
epoch_time = stats.st_mtime.__trunc__()
except:
print('Cant access: ' + str(path))
size = 0
epoch_time = 0
file_list.append(
('0', utf_path, size, epoch_time))

Expand Down

0 comments on commit fdec88e

Please sign in to comment.