Follow up to the previous commit fixing hangs when previewing named pipes:
- Skip previewing anything that is not a regular file (or a symlink to
one) in preview_for, before any previewer opens it. This avoids
unblocking and then breaking writers waiting on a FIFO and covers the
non-text previewers (images, video, archives, calibre, commands) too.
- Apply the text preview size limit to the symlink target instead of the
symlink itself, and enforce it while reading so that files growing
after stat() are also handled.
- Pre-allocate the read buffer based on the file size, as os.ReadFile does.
- Read ignore files during scanning with the same non-blocking reader, so
a FIFO named .ignore or .gitignore cannot stall the scan.
- Unblock goroutines stuck on FIFOs when tests time out.
Open text preview files in nonblocking mode and check the type on
the opened descriptor before reading. Reuse the same read for syntax
highlighting because it can reopen a path after the file changes.
Use Capture.ByteRange() from v2 instead of a hand-rolled rune to byte
offset mapping. The old mapping required capture offsets to be monotonic
across matches, so a capture inside a lookaround overlapping a later match
in non-ASCII text caused all matches to be silently dropped.
Also propagate match errors instead of discarding them. Drops the v1
dependency, v2 was already pulled in by chroma.
Keep edit_loop free of side effects: it now reports whether the editor
was started and edit_and_upload decides whether to keep the local copy.
Print the recovery path verbatim instead of Go-quoted.
Strip the optional leading = from values attached to short options, matching
rg semantics (-e=foo means the pattern foo). Replace the rg execution based
test with unit tests of the argument rewriting.
Move the D-Bus service Exec line generation into a helper with a fast unit
test instead of copying the test binary and re-executing it. Refuse paths
containing a carriage return, since D-Bus decodes \r as a newline and
rejects .service files containing a raw carriage return.
enable_portal checked eerr instead of err after filepath.Abs, so a failing
os.Executable always aborted with a nil error and the Which fallback was
never used, while an Abs error was ignored. Check err, and report the
os.Executable error if kitten is not in PATH either.
Track move source identities in drop_status rather than parsed_uri, and
also compare birth times where available, so that a replacement reusing
the inode number of a deleted source is not removed. Clarify the
changelog entry.
is_case_sensitive_filesystem lost its true default when it moved into
the dnd struct, so remote drops always treated names differing only in
case as conflicting. Detect it properly and also probe for Unicode
normalization aliasing, since a case sensitive filesystem can still
treat differently normalized names as the same.
- List the existing files that will be overwritten under the names they
are stored as in the destination, not the dropped names
- Treat symlinks to directories in the destination as directories in
find_overwrites, matching rename_contents, so the files that will be
overwritten inside the symlink target are listed
- Replace an existing file or dangling symlink with a dropped directory
instead of failing the drop after the user confirmed the overwrite
- Fail up front when a dropped file would replace an existing directory
- Also fold Unicode normalization when uniqifying remote drop names
- Probe for filesystem aliasing once before running the alias test
Walk up from the drop destination using .. relative to its file
descriptor instead of its path, so the check is not fooled if the
destination is moved or replaced while the kitten is running. Also skip
the staging directory when copying, which guards against routes to it
the up-front check cannot see, such as bind mounts. Use readable
subtest names, check the chmod error in test cleanup and link the PR in
the changelog.
Staging two entries with the same basename could fall back from a hard link to a truncating copy and overwrite the first source. Give each local source an unused staging name and use exclusive file and directory creation. Add regressions for files, directories, repeated paths, case conflicts, existing staging entries and symbolic links.
Identify the colliding output by comparing the probe files, matching the
message used for exact duplicates. Skip creating probe files when fewer
than two file outputs are given, so that a single output does not touch
the destination directory. Check both directories for leftover probes in
the test.
Rather than every output sharing a remote MIME type writing its own
temporary copy of the data and decoding images separately, store the
data in a single temporary file per MIME type, decode images once and
save all outputs for that MIME type sequentially from it. The temporary
file is created in the directory of the first output where that is
possible, so a missing directory for one output does not affect others.
Also reject output files that resolve to the same path, following
symlinks as the atomic file update does, since saving to them would race
with the last write winning.
Stream outputs write data as it arrives, so with fan-out to all outputs
sharing a remote MIME type, two outputs to the same stream would
interleave their data chunk by chunk, or encode two images into the
stream concurrently. Reject such duplicates with an error instead.
Also add a changelog entry for saving all outputs sharing a MIME type.
Move writing the MIME list into Output.write_mime_list() and test it
directly. Committing, permission preservation and failure cleanup are
already covered by the existing Output commit tests, so the PTY test
that spawned the kitten only added coverage for the missing commit.
Follow up to the merge of #10738. Use utils.AtomicUpdateFile to move
downloaded data into place instead of hand rolling the stat/chmod/rename
sequence. This fixes:
- Permissions of existing destination files not being preserved, as the
chmod was applied to an already closed file
- An empty file being left at the destination if the rename failed, as
the permissions probe opened the destination with O_CREATE
- Symlinks at the destination being replaced by regular files
- No fsync before the rename
Also encode converted images into memory and write them atomically, so
a failed encode no longer truncates and then deletes an existing
destination file.
The copied paths have their symlinks resolved, so files under a HOME that is
itself reached via a symlink, such as /home -> /usr/home, were not
recognized as being in HOME and were copied to an absolute path on the
remote machine. Also add the PR reference to the changelog entry for #10737.