Commit graph

247 commits

Author SHA1 Message Date
Kovid Goyal
ef58de6850
Transfer kitten: Replace existing links when receiving files
Receiving a regular file over an existing symlink or hard link used to
truncate and overwrite the file the link points to. Instead, write
received files to a temporary file in the destination directory and
atomically rename it into place once the transfer completes, as was
already done for delta transfers. This also means interrupted transfers
no longer leave truncated files behind.

If the destination directory is not writable, fall back to writing in
place, but only for regular files with a single link, so that no other
file can be affected.

Also use stat rather than lstat when deciding whether to use delta
transfers, so that symlinks to large files can use them, and remove
the temporary file of failed or aborted delta transfers.

Closes #10713
2026-10-21 20:35:07 +05:30
Kovid Goyal
05d3ee35ff
Transfer kitten: Clearer errors when the destination is a directory
Refuse to replace an existing directory, or a symlink to a directory, with
a file, reporting EISDIR before any data is transferred instead of a raw
OSError (or silently replacing the symlink). Report failures to create
parent directories with the actual errno and directory name. When a send
fails, the kitten now prints hints for the common causes: a missing
trailing slash on a directory destination and a ~ expanded by the shell
on the remote machine.

Fixes #8118
Closes #10710
2026-10-21 06:14:21 +05:30
Kovid Goyal
56deb9e86d
transfer kitten: Fix receiving empty files
Some checks are pending
CI / Linux (python=3.14 cc=clang sanitize=1) (push) Waiting to run
CI / Linux (python=3.12 cc=gcc sanitize=0) (push) Waiting to run
CI / Linux (python=3.13 cc=gcc sanitize=1) (push) Waiting to run
CI / Linux package (push) Waiting to run
CI / Bundle test (macos-latest) (push) Waiting to run
CI / Bundle test (ubuntu-latest) (push) Waiting to run
CI / macOS Brew (push) Waiting to run
CI / Test ./dev.sh and benchmark (push) Waiting to run
CodeQL / CodeQL-Build (actions, ubuntu-latest) (push) Waiting to run
CodeQL / CodeQL-Build (c, macos-latest) (push) Waiting to run
CodeQL / CodeQL-Build (c, ubuntu-latest) (push) Waiting to run
CodeQL / CodeQL-Build (go, ubuntu-latest) (push) Waiting to run
CodeQL / CodeQL-Build (python, ubuntu-latest) (push) Waiting to run
Depscan / Scan dependencies for vulnerabilities (push) Waiting to run
The output file for a regular file was only created when the
decompressor first emitted data, which never happens for an empty file.
So empty files were not created and existing destination files were
left with their old contents. Open the output file as soon as the first
chunk for a regular file arrives instead.

Closes #10689
2026-10-18 14:33:13 +05:30
Kovid Goyal
e55d14085a
Cleanup previous PR
- Parse in-band resize reports robustly: require the 48; prefix, accept
  extra parameters and reject negative values instead of panicking
- Handle bracketed paste in parse_input_from_terminal with a dedicated
  scan for the end of paste marker so pasted escape bytes are never lost
- Guard against NaN in scroll_by_pixels and scroll_to_absolute, clamp
  negative absolute scroll targets, let infinite fractional scrolls clamp
  and propagate overflow errors from PyLong_AsDouble
- Empty disk cache entries no longer claim offset 0 in the cache file and
  defrag only moves entries actually written to disk
- Reject zero and too large block sizes in rsync signature headers
- Only replace the encryptor tag once it has been read successfully
2026-10-09 18:37:48 +05:30
rudolf-blue
cf114eab28 Fix leak of rsync hasher state when parsing the signature header 2026-10-09 07:40:55 -04:00
Kovid Goyal
b60a8d333e
Fix remote path sanitisation 2026-08-24 18:37:15 +05:30
Kovid Goyal
2af2d313de
autoformat c/objc code, using clang-format with left alignment for line continuation chars 2026-08-05 19:37:00 +05:30
Kovid Goyal
4c6467814b
autoformat c/objc code, using clang-format 2026-08-05 19:10:55 +05:30
Kovid Goyal
7f0b072f0d
autoformat 2026-08-05 05:32:56 +05:30
Kovid Goyal
3d8a2fbb4f
Use SIMD base64 everywhere 2026-04-21 11:56:55 +05:30
Kovid Goyal
6f588a0c29
run modernize 2025-11-11 17:09:37 +05:30
Kovid Goyal
1544cab96f
Fix #8901 2025-08-14 19:33:43 +05:30
Kovid Goyal
08f9c0c100
... 2025-08-14 18:58:53 +05:30
Kovid Goyal
62580c855b
Make mypy 1.16 happy 2025-05-30 10:06:38 +05:30
Kovid Goyal
c861259e3b
Rename go module from kitty -> github.com/kovidgoyal/kitty
Makes the code more easily re-useable in other projects
2025-05-16 08:43:39 +05:30
Kovid Goyal
d548a6fcf4
rename typing module to avoid conflicts with stdlib typing 2025-04-28 09:20:10 +05:30
Kovid Goyal
e42d410ee4
Move cli spec parsing code into simple module 2025-04-28 09:20:10 +05:30
Kovid Goyal
da1626090a
Update codebase to Python 3.10 using pyupgrade 2025-02-03 10:56:50 +05:30
Kovid Goyal
e97c225b6c
Add *_into API for streaming encode/decode 2024-07-30 07:18:33 +05:30
Kovid Goyal
a473738001
Add tests for handling of icon metadata 2024-07-26 23:57:36 +05:30
Kovid Goyal
dca2663500
move rsync signature hashmap to verstable 2024-07-12 11:45:48 +05:30
Kovid Goyal
405f5ce148
Use stdlib maps/slices 2024-06-24 07:54:13 +05:30
Kovid Goyal
4d9b1b81ea
Fix #7426 2024-05-13 08:35:17 +05:30
Kovid Goyal
c5f0b03a62
Remove not needed function 2024-02-25 09:57:29 +05:30
Kovid Goyal
c10ea63818
Implement local filename completion for the transfer kitten 2023-11-25 07:46:30 +05:30
Kovid Goyal
c03dff2322
Fix help text and short desc for the two wrapper kittens 2023-10-17 19:50:47 +05:30
Bernhard M. Wiedemann
17b7703dab Fix compilation without LTO
When building without link-time-optimization through the
KITTY_NO_LTO env var or the setup.py --disable-link-time-optimization option
compilation failed with a warning about freeing "ans" memory.

Chances are, this is dead code that gets optimized out by LTO.
2023-10-08 04:52:24 +02:00
Kovid Goyal
a8633756de
More linter fixes 2023-09-18 21:36:34 +05:30
Kovid Goyal
1a32e62ebf
More linter fixes 2023-09-18 21:07:39 +05:30
Kovid Goyal
85005eee1b
receive kitten: Send signature in 4KB blocks 2023-08-10 11:10:55 +05:30
Kovid Goyal
47af65dc5c
Ensure transmit next chunk is called 2023-08-10 07:51:13 +05:30
Kovid Goyal
4f72bb9894
Replace utils.Once with stdlib sync.OnceValue 2023-08-09 12:08:42 +05:30
Kovid Goyal
f125ffe3e0
Fix a hang in the send kitten when transmitting deltas of multiple files
and the files have not changed causing the signature of the second file
to arrive after the delta for the first file is transmitted
2023-08-09 08:25:18 +05:30
Kovid Goyal
12bdc0cc0c
... 2023-08-08 17:51:02 +05:30
Kovid Goyal
a628609ca8
Fix incorrect ETA calculation for active file 2023-08-08 17:45:28 +05:30
Kovid Goyal
1c251e5a53
More fixes for send kitten 2023-08-08 17:26:16 +05:30
Kovid Goyal
0e87e0c7de
Work on refactoring send kitten to fix various issues 2023-08-08 06:28:43 +05:30
Kovid Goyal
95c7934152
Use an atomic update for erase + draw not only draw 2023-08-07 13:55:22 +05:30
Kovid Goyal
6c7a8f8fa9
Ensure usage of __attribute__(cleanup) never frees un-initialized memory
Use macros that take an initializer parameter to, thereby ensuring the
variable to be cleaned up is always initialized.
2023-08-07 12:24:18 +05:30
Kovid Goyal
b34a479080
Fix multiple finish cmds at end of send
Also improve queuing of chunks
2023-08-05 13:59:07 +05:30
Kovid Goyal
341d845b9a
Port calls to slices.Sort functions since they now need a cmp() function rather than a less() function
Also rename os.SEEK_* to io.Seek* as the former has been deprecated
2023-08-04 22:50:13 +05:30
Kovid Goyal
1c094a3b53
Cleanup user docs for transfer kitten 2023-07-30 19:49:47 +05:30
Kovid Goyal
c11d1d3430
Add more integration testing for the transfer kitten 2023-07-30 19:49:47 +05:30
Kovid Goyal
47913a7c1f
Tests for normal mode home dir expansion 2023-07-30 19:49:47 +05:30
Kovid Goyal
995c447435
Get the multi file tests working for the receive kitten 2023-07-30 19:49:47 +05:30
Kovid Goyal
e4986c489e
Ignore EINTR 2023-07-30 19:49:47 +05:30
Kovid Goyal
ce593dbb5f
lp.Println() should act live fmt.Println()
also use a dedicated error type for signalining perm denied
2023-07-30 19:49:47 +05:30
Kovid Goyal
d2d91401af
Fix the tree walker 2023-07-30 19:49:47 +05:30
Kovid Goyal
bd231eaf39
Fix local base being ignored in make_tree 2023-07-30 19:49:47 +05:30
Kovid Goyal
141edb975e
Misc fixes 2023-07-30 19:49:47 +05:30