Skip to content

core: skip unreadable KDE config entries during save - #563

Merged
vikdevelop merged 1 commit into
vikdevelop:mainfrom
CGIFM:fix/kde-config-unreadable-entries
Nov 11, 2026
Merged

vikdevelop merged 1 commit into
vikdevelop:mainfrom
CGIFM:fix/kde-config-unreadable-entries

Conversation

@CGIFM

@CGIFM CGIFM commented Nov 10, 2026

Copy link
Copy Markdown

What

When saving KDE configuration, a single unreadable entry no longer aborts the whole backup: the entry is reported and skipped, and the remaining directories are still copied.

Why

On Kubuntu 26.10, saving fails with shutil.Error ... [Errno 13] Permission denied as soon as any k* entry under ~/.config or ~/.local/share cannot be read. In the report this is ~/.config/kudu, a Chromium-based app whose storage files are locked while the app is running. The user gets no backup at all instead of a backup missing one file. Fixes #562.

Reproduction

With a temporary HOME containing ~/.config/kudu/locked.db, keep that file open so reads fail (Linux: chmod 000, errno 13; Windows: exclusive open, WinError 32), then call Save.save_kde_config_data_dirs():

python repro.py
RESULT: Error: [('.../home/.config/kudu/locked.db', 'DE\\xdg-config\\kudu\\locked.db',
                 '[WinError 32] ...')]

This is the same shutil.Error raised in the issue's traceback. After the patch the same run prints:

[ERR] Dir copy failed .../home/.config/kudu -> DE\xdg-config\kudu: [...]
RESULT: save completed without raising

Root cause

src/core/de_config.py:346 and :348 called shutil.copytree / shutil.copy2 directly. Every other save path in this module goes through the safe_copytree / safe_copy helpers defined at the top of the file (28 call sites), whose contract is to log [ERR] and continue. This KDE-specific helper (added in 36876fd) missed the wrappers, so an unreadable entry propagates out of Save.__init__ and aborts the entire save.

Verification

  • New regression test tests/test_kde_config_save.py (stdlib unittest, no new dependency):
    • baseline 4689e84: python -m unittest discover -v → FAILED (errors=1), shutil.Error: ... locked.db
    • patched: same command → Ran 3 tests ... OK
  • Full suite: the repository had no tests before; python -m compileall -q src + python -m unittest discover -v run twice, both green.
  • Targeted test run 3 times, green each time (no flake).
  • Adversarial checks: locked file nested two levels deep, pre-existing stale target directory, Unicode/space directory name, locked file under ~/.local/share, dangling symlink. Save completes in all cases.
  • kdeconnect exclusion and "no k* entries" behavior are covered by tests.

Risk

  • The failing directory is partially copied: readable files are kept, the locked file is skipped, and an [ERR] line is logged. This matches how the rest of the save pipeline already handles unreadable directories.
  • k* entries now use safe_copytree, which preserves symlinks (symlinks=True) instead of dereferencing them, consistent with the other directory copies in Save. I can keep the previous dereferencing behavior if that is preferred.
  • Deleting a stale target (shutil.rmtree) is unchanged.
  • No change for readable entries; paths and output format of successful copies are identical.

@vikdevelop

Copy link
Copy Markdown
Owner

Thank you for your contribution!

@vikdevelop
vikdevelop merged commit e75f79d into vikdevelop:main Nov 11, 2026
1 check failed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

bug: Does not save on Kubuntu 26.10

2 participants