fix: page hint for comment list, keep SSH settings on re-login, hard-link-free downloads, stable OWNER/REPO#N instance (follow gh)

Signed-off-by: bircni <bircni@icloud.com>
This commit is contained in:
bircni committed 2026-10-18 20:03:15 +02:00
1 parent dfb56eae67
commit 8305a89531
11 files changed
+154 -10

No files matched your search

+32
View File
@@ -172,6 +172,38 @@ func publish(cmd *cobra.Command, output string, private, replace bool, write fun
if errors.Is(err, os.ErrExist) {
return clierr.Wrap(clierr.Usage, fmt.Errorf("%s already exists", output))
}
if err != nil {
// Some filesystems, such as FAT and many network mounts, cannot hard link.
return copyExclusive(file.Name(), output, private, err)
}
return nil
}
// copyExclusive copies the finished temporary file to output, which must not exist, when linking
// failed with linkErr. A failed copy removes the partial output.
func copyExclusive(temporary, output string, private bool, linkErr error) error {
mode := os.FileMode(0o666)
if private {
mode = 0o600
}
destination, err := os.OpenFile(output, os.O_WRONLY|os.O_CREATE|os.O_EXCL, mode)
if errors.Is(err, os.ErrExist) {
return clierr.Wrap(clierr.Usage, fmt.Errorf("%s already exists", output))
}
if err != nil {
return linkErr
}
source, err := os.Open(temporary)
if err == nil {
defer source.Close()
_, err = io.Copy(destination, source)
}
if closeErr := destination.Close(); err == nil {
err = closeErr
}
if err != nil {
_ = os.Remove(output)
}
return err
}