fix: clean up empty file after failed wl-paste clipboard extraction

When wl-paste produces empty output, the destination file was left as
a 0-byte orphan. Added dest.unlink() before returning False, matching
the existing cleanup pattern in the exception handler.

Authored by 0xbyt4.

Co-authored-by: 0xbyt4 <0xbyt4@users.noreply.github.com>
This commit is contained in:
teknium1
2026-03-11 02:56:19 -07:00

View File

@@ -254,6 +254,7 @@ def _wayland_save(dest: Path) -> bool:
) )
if not dest.exists() or dest.stat().st_size == 0: if not dest.exists() or dest.stat().st_size == 0:
dest.unlink(missing_ok=True)
return False return False
# BMP needs conversion to PNG (common in WSLg where only BMP # BMP needs conversion to PNG (common in WSLg where only BMP