| Index: client/utils/file_path.py
|
| diff --git a/client/utils/file_path.py b/client/utils/file_path.py
|
| index 85491e8f7459a8cf51592511dc4291f21d6dd6ee..8675e3b1754dbe8277dac8841feab9265411555f 100644
|
| --- a/client/utils/file_path.py
|
| +++ b/client/utils/file_path.py
|
| @@ -726,18 +726,23 @@ def set_read_only_swallow(path, read_only):
|
| return e
|
|
|
|
|
| +def remove(filepath):
|
| + """Removes a file, even if it is read-only."""
|
| + # TODO(maruel): Not do it unless necessary since it slows this function
|
| + # down.
|
| + if sys.platform == 'win32':
|
| + # Deleting a read-only file will fail if it is read-only.
|
| + set_read_only(filepath, False)
|
| + else:
|
| + # Deleting a read-only file will fail if the directory is read-only.
|
| + set_read_only(os.path.dirname(filepath), False)
|
| + fs.remove(filepath)
|
| +
|
| +
|
| def try_remove(filepath):
|
| """Removes a file without crashing even if it doesn't exist."""
|
| try:
|
| - # TODO(maruel): Not do it unless necessary since it slows this function
|
| - # down.
|
| - if sys.platform == 'win32':
|
| - # Deleting a read-only file will fail if it is read-only.
|
| - set_read_only(filepath, False)
|
| - else:
|
| - # Deleting a read-only file will fail if the directory is read-only.
|
| - set_read_only(os.path.dirname(filepath), False)
|
| - fs.remove(filepath)
|
| + remove(filepath)
|
| except OSError:
|
| pass
|
|
|
|
|