Commit e257825
fix(extensions): preserve-capture only from a real dir; reset non-dir dest_dir in main path
Two more symlink-safety fixes to the keep-config reinstall:
1. The preserved-config capture guarded on dest_dir.exists(), which is true for a
symlink; iterating a symlinked dest_dir would follow the link and read
arbitrary external files into preserved_configs. Require a real directory
(is_dir() and not is_symlink()) so only genuine on-disk leftover configs are
captured.
2. The main install path cleared dest_dir with shutil.rmtree(dest_dir), which
raises on a symlink or file (NotADirectoryError) and didn't benefit from the
_reset_dir behavior already used in rollback. Use self._reset_dir(dest_dir) so
an unexpected occupant (symlink/file) is handled consistently instead of
crashing on path type.
Tests: a stray FILE at dest_dir is replaced cleanly (cross-platform; fails before
with NotADirectoryError), and the capture ignores a symlinked dest_dir without
reading/overwriting external files (skipped without symlink privilege, runs on CI).
Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>1 parent 5246aaa commit e257825
2 files changed
Lines changed: 66 additions & 3 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1519 | 1519 | | |
1520 | 1520 | | |
1521 | 1521 | | |
1522 | | - | |
| 1522 | + | |
| 1523 | + | |
| 1524 | + | |
| 1525 | + | |
| 1526 | + | |
1523 | 1527 | | |
1524 | 1528 | | |
1525 | 1529 | | |
| |||
1561 | 1565 | | |
1562 | 1566 | | |
1563 | 1567 | | |
1564 | | - | |
1565 | | - | |
| 1568 | + | |
| 1569 | + | |
| 1570 | + | |
| 1571 | + | |
1566 | 1572 | | |
1567 | 1573 | | |
1568 | 1574 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1870 | 1870 | | |
1871 | 1871 | | |
1872 | 1872 | | |
| 1873 | + | |
| 1874 | + | |
| 1875 | + | |
| 1876 | + | |
| 1877 | + | |
| 1878 | + | |
| 1879 | + | |
| 1880 | + | |
| 1881 | + | |
| 1882 | + | |
| 1883 | + | |
| 1884 | + | |
| 1885 | + | |
| 1886 | + | |
| 1887 | + | |
| 1888 | + | |
| 1889 | + | |
| 1890 | + | |
| 1891 | + | |
| 1892 | + | |
| 1893 | + | |
| 1894 | + | |
| 1895 | + | |
| 1896 | + | |
| 1897 | + | |
| 1898 | + | |
| 1899 | + | |
| 1900 | + | |
| 1901 | + | |
| 1902 | + | |
| 1903 | + | |
| 1904 | + | |
| 1905 | + | |
| 1906 | + | |
| 1907 | + | |
| 1908 | + | |
| 1909 | + | |
| 1910 | + | |
| 1911 | + | |
| 1912 | + | |
| 1913 | + | |
| 1914 | + | |
| 1915 | + | |
| 1916 | + | |
| 1917 | + | |
| 1918 | + | |
| 1919 | + | |
| 1920 | + | |
| 1921 | + | |
| 1922 | + | |
| 1923 | + | |
| 1924 | + | |
| 1925 | + | |
| 1926 | + | |
| 1927 | + | |
| 1928 | + | |
| 1929 | + | |
1873 | 1930 | | |
1874 | 1931 | | |
1875 | 1932 | | |
| |||
0 commit comments