Skip to content

Commit

Permalink
LocalTransport.remove_tree(): Ignore failures when removing non-exist…
Browse files Browse the repository at this point in the history
…ent filesystem entry.
  • Loading branch information
riccardomurri committed Apr 27, 2018
1 parent 4e3483f commit 25a688c
Showing 1 changed file with 9 additions and 5 deletions.
14 changes: 9 additions & 5 deletions gc3libs/backends/transport.py
Expand Up @@ -6,7 +6,7 @@
destination is the local computer or a remote front-end that we access
via SSH.
"""
# Copyright (C) 2009-2017 University of Zurich. All rights reserved.
# Copyright (C) 2009-2018 University of Zurich. All rights reserved.
#
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU Lesser General Public License as published by
Expand Down Expand Up @@ -1175,10 +1175,14 @@ def remove_tree(self, path):
gc3libs.log.debug("LocalTransport.remove_tree():"
" removing local directory tree '%s'" % path)
return shutil.rmtree(path)
except Exception as ex:
raise gc3libs.exceptions.TransportError(
"Could not remove directory tree '%s': %s: %s"
% (path, ex.__class__.__name__, str(ex)))
except OSError as err:
if err.errno == errno.ENOENT:
# ignore "No such file or directory"
pass
else:
raise gc3libs.exceptions.TransportError(
"Could not remove directory tree '%s': %s: %s"
% (path, ex.__class__.__name__, err))

@same_docstring_as(Transport.stat)
def stat(self, path):
Expand Down

0 comments on commit 25a688c

Please sign in to comment.