diff options
| -rw-r--r-- | project.py | 32 |
1 files changed, 22 insertions, 10 deletions
| @@ -1848,7 +1848,7 @@ class Project: | |||
| 1848 | platform_utils.remove(path) | 1848 | platform_utils.remove(path) |
| 1849 | except OSError as e: | 1849 | except OSError as e: |
| 1850 | if e.errno != errno.ENOENT: | 1850 | if e.errno != errno.ENOENT: |
| 1851 | logger.error("error: %s: Failed to remove: %s", path, e) | 1851 | logger.warning("%s: Failed to remove: %s", path, e) |
| 1852 | failed = True | 1852 | failed = True |
| 1853 | errors.append(e) | 1853 | errors.append(e) |
| 1854 | dirs[:] = [ | 1854 | dirs[:] = [ |
| @@ -1867,7 +1867,7 @@ class Project: | |||
| 1867 | platform_utils.remove(d) | 1867 | platform_utils.remove(d) |
| 1868 | except OSError as e: | 1868 | except OSError as e: |
| 1869 | if e.errno != errno.ENOENT: | 1869 | if e.errno != errno.ENOENT: |
| 1870 | logger.error("error: %s: Failed to remove: %s", d, e) | 1870 | logger.warning("%s: Failed to remove: %s", d, e) |
| 1871 | failed = True | 1871 | failed = True |
| 1872 | errors.append(e) | 1872 | errors.append(e) |
| 1873 | elif not platform_utils.listdir(d): | 1873 | elif not platform_utils.listdir(d): |
| @@ -1875,18 +1875,30 @@ class Project: | |||
| 1875 | platform_utils.rmdir(d) | 1875 | platform_utils.rmdir(d) |
| 1876 | except OSError as e: | 1876 | except OSError as e: |
| 1877 | if e.errno != errno.ENOENT: | 1877 | if e.errno != errno.ENOENT: |
| 1878 | logger.error("error: %s: Failed to remove: %s", d, e) | 1878 | logger.warning("%s: Failed to remove: %s", d, e) |
| 1879 | failed = True | 1879 | failed = True |
| 1880 | errors.append(e) | 1880 | errors.append(e) |
| 1881 | if failed: | 1881 | if failed: |
| 1882 | logger.error( | 1882 | rename_path = ( |
| 1883 | "error: %s: Failed to delete obsolete checkout.", | 1883 | f"{self.worktree}_repo_to_be_deleted_{int(time.time())}" |
| 1884 | self.RelPath(local=False), | ||
| 1885 | ) | 1884 | ) |
| 1886 | logger.error( | 1885 | try: |
| 1887 | " Remove manually, then run `repo sync -l`.", | 1886 | platform_utils.rename(self.worktree, rename_path) |
| 1888 | ) | 1887 | logger.warning( |
| 1889 | raise DeleteWorktreeError(aggregate_errors=errors) | 1888 | "warning: renamed %s to %s. You can delete it, but you " |
| 1889 | "might need elevated permissions (e.g. root)", | ||
| 1890 | self.worktree, | ||
| 1891 | rename_path, | ||
| 1892 | ) | ||
| 1893 | # Rename successful! Clear the errors. | ||
| 1894 | errors = [] | ||
| 1895 | except OSError: | ||
| 1896 | logger.error( | ||
| 1897 | "%s: Failed to delete obsolete checkout.\n", | ||
| 1898 | " Remove manually, then run `repo sync -l`.", | ||
| 1899 | self.RelPath(local=False), | ||
| 1900 | ) | ||
| 1901 | raise DeleteWorktreeError(aggregate_errors=errors) | ||
| 1890 | 1902 | ||
| 1891 | # Try deleting parent dirs if they are empty. | 1903 | # Try deleting parent dirs if they are empty. |
| 1892 | path = self.worktree | 1904 | path = self.worktree |
