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

Side by Side 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 unified diff | Download patch
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 # Copyright 2013 The LUCI Authors. All rights reserved. 1 # Copyright 2013 The LUCI Authors. All rights reserved.
2 # Use of this source code is governed under the Apache License, Version 2.0 2 # Use of this source code is governed under the Apache License, Version 2.0
3 # that can be found in the LICENSE file. 3 # that can be found in the LICENSE file.
4 4
5 """Provides functions: get_native_path_case(), isabs() and safe_join(). 5 """Provides functions: get_native_path_case(), isabs() and safe_join().
6 6
7 This module assumes that filesystem is not changing while current process 7 This module assumes that filesystem is not changing while current process
8 is running and thus it caches results of functions that depend on FS state. 8 is running and thus it caches results of functions that depend on FS state.
9 """ 9 """
10 10
(...skipping 1148 matching lines...) Expand 10 before | Expand all | Expand 10 after
1159 time.sleep((i+1)*2) 1159 time.sleep((i+1)*2)
1160 else: 1160 else:
1161 processes = get_processes() 1161 processes = get_processes()
1162 if processes: 1162 if processes:
1163 sys.stderr.write('Failed to terminate processes.\n') 1163 sys.stderr.write('Failed to terminate processes.\n')
1164 raise errors[0][2][0], errors[0][2][1], errors[0][2][2] 1164 raise errors[0][2][0], errors[0][2][1], errors[0][2][2]
1165 1165
1166 # Now that annoying processes in root are evicted, try again. 1166 # Now that annoying processes in root are evicted, try again.
1167 errors = [] 1167 errors = []
1168 fs.rmtree(root, onerror=lambda *args: errors.append(args)) 1168 fs.rmtree(root, onerror=lambda *args: errors.append(args))
1169 if errors: 1169 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
1170 # There's no hope. 1170 # There's no hope: the directory was tried to be removed 4 times. Give up
1171 # and raise an exception.
1171 sys.stderr.write( 1172 sys.stderr.write(
1172 'Failed to delete %s. The following files remain:\n' % root) 1173 'Failed to delete %s. The following files remain:\n' % root)
1173 for _, path, _ in errors: 1174 # The same path may be listed multiple times.
1175 for path in sorted(set(path for _, path, _ in errors)):
1174 sys.stderr.write('- %s\n' % path) 1176 sys.stderr.write('- %s\n' % path)
1175 raise errors[0][2][0], errors[0][2][1], errors[0][2][2] 1177 raise errors[0][2][0], errors[0][2][1], errors[0][2][2]
1176 return False 1178 return False
OLDNEW
« 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