| OLD | NEW |
| 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 728 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 739 set_read_only(os.path.dirname(filepath), False) | 739 set_read_only(os.path.dirname(filepath), False) |
| 740 fs.remove(filepath) | 740 fs.remove(filepath) |
| 741 except OSError: | 741 except OSError: |
| 742 pass | 742 pass |
| 743 | 743 |
| 744 | 744 |
| 745 def link_file(outfile, infile, action): | 745 def link_file(outfile, infile, action): |
| 746 """Links a file. The type of link depends on |action|. | 746 """Links a file. The type of link depends on |action|. |
| 747 | 747 |
| 748 Returns: | 748 Returns: |
| 749 True if the action was caried on, False if fallback was used. | 749 True if the action was carried on, False if fallback was used. |
| 750 """ | 750 """ |
| 751 if action not in (HARDLINK, HARDLINK_WITH_FALLBACK, SYMLINK, COPY): | 751 if action not in (HARDLINK, HARDLINK_WITH_FALLBACK, SYMLINK, COPY): |
| 752 raise ValueError('Unknown mapping action %s' % action) | 752 raise ValueError('Unknown mapping action %s' % action) |
| 753 if not fs.isfile(infile): | 753 if not fs.isfile(infile): |
| 754 raise OSError('%s is missing' % infile) | 754 raise OSError('%s is missing' % infile) |
| 755 if fs.isfile(outfile): | 755 if fs.isfile(outfile): |
| 756 raise OSError( | 756 raise OSError( |
| 757 '%s already exist; insize:%d; outsize:%d' % | 757 '%s already exist; insize:%d; outsize:%d' % |
| 758 (outfile, fs.stat(infile).st_size, fs.stat(outfile).st_size)) | 758 (outfile, fs.stat(infile).st_size, fs.stat(outfile).st_size)) |
| 759 | 759 |
| (...skipping 265 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1025 errors = [] | 1025 errors = [] |
| 1026 fs.rmtree(root, onerror=lambda *args: errors.append(args)) | 1026 fs.rmtree(root, onerror=lambda *args: errors.append(args)) |
| 1027 if errors: | 1027 if errors: |
| 1028 # There's no hope. | 1028 # There's no hope. |
| 1029 sys.stderr.write( | 1029 sys.stderr.write( |
| 1030 'Failed to delete %s. The following files remain:\n' % root) | 1030 'Failed to delete %s. The following files remain:\n' % root) |
| 1031 for _, path, _ in errors: | 1031 for _, path, _ in errors: |
| 1032 sys.stderr.write('- %s\n' % path) | 1032 sys.stderr.write('- %s\n' % path) |
| 1033 raise errors[0][2][0], errors[0][2][1], errors[0][2][2] | 1033 raise errors[0][2][0], errors[0][2][1], errors[0][2][2] |
| 1034 return False | 1034 return False |
| OLD | NEW |