Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(241)

Unified Diff: client/utils/file_path.py

Issue 2934983003: Improve error handling for file_path.rmtree() (Closed)
Patch Set: Created 3 years, 6 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: client/utils/file_path.py
diff --git a/client/utils/file_path.py b/client/utils/file_path.py
index 6cb52d1b6eb46e3ccc7d66870519e3ab2c9713df..fd4ba9aa6c55856224536fac7a4a64a8a4551bdd 100644
--- a/client/utils/file_path.py
+++ b/client/utils/file_path.py
@@ -1166,11 +1166,13 @@ def rmtree(root):
# Now that annoying processes in root are evicted, try again.
errors = []
fs.rmtree(root, onerror=lambda *args: errors.append(args))
- if errors:
- # There's no hope.
+ if errors and fs.exists(root):
Vadim Sh. 2017/06/13 20:49:01 as far as I can tell, this code path is not hit on
+ # There's no hope: the directory was tried to be removed 4 times. Give up
+ # and raise an exception.
sys.stderr.write(
'Failed to delete %s. The following files remain:\n' % root)
- for _, path, _ in errors:
+ # The same path may be listed multiple times.
+ for path in sorted(set(path for _, path, _ in errors)):
sys.stderr.write('- %s\n' % path)
raise errors[0][2][0], errors[0][2][1], errors[0][2][2]
return False
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698