Skip to content

Commit

Permalink
Bugfix, trying to delete non-existing file.
Browse files Browse the repository at this point in the history
I wanted to drop a release on the world, but luckily
Li Xing sent me a comment on my new removal implementation.

Any other bugs will have to be resolved in 0.1.5.. I'm ready
to release 0.1.4 and see what happens next.
  • Loading branch information
bneijt committed Nov 19, 2010
1 parent 1284e9d commit bd72f77
Showing 1 changed file with 6 additions and 2 deletions.
8 changes: 6 additions & 2 deletions autotrash
Original file line number Diff line number Diff line change
Expand Up @@ -81,8 +81,12 @@ def purge(trash_directory, trash_name, dryrun):
logging.log(VERBOSE, 'Removing directory %s', target)
shutil.rmtree(target, False, on_remove_error)
else:
logging.log(VERBOSE, 'Removing file %s', target)
os.unlink(target)
#Make sure we do not try to unlink a file that does not exist.
if os.path.exists(target):
logging.log(VERBOSE, 'Removing file %s', target)
os.unlink(target)
else:
logging.log(VERBOSE, 'Ignore non-existing file %s', target)

os.unlink(trash_name)
return True
Expand Down

0 comments on commit bd72f77

Please sign in to comment.