0
0
Fork 0
mirror of https://github.com/schollz/croc.git synced 2025-10-11 13:21:00 +02:00

fix long file name

This commit is contained in:
Asuka Minato 2024-09-01 21:39:40 +09:00
parent 90ed1f797e
commit 319a403082

View file

@ -1698,7 +1698,12 @@ func (c *Client) recipientGetFileReady(finished bool) (err error) {
c.Step3RecipientRequestFile = true c.Step3RecipientRequestFile = true
return return
} }
func max(a int, b int) int {
if a > b {
return a
}
return b
}
func (c *Client) createEmptyFileAndFinish(fileInfo FileInfo, i int) (err error) { func (c *Client) createEmptyFileAndFinish(fileInfo FileInfo, i int) (err error) {
log.Debugf("touching file with folder / name") log.Debugf("touching file with folder / name")
if !utils.Exists(fileInfo.FolderRemote) { if !utils.Exists(fileInfo.FolderRemote) {
@ -1737,6 +1742,7 @@ func (c *Client) createEmptyFileAndFinish(fileInfo FileInfo, i int) (err error)
description = " " + description description = " " + description
} }
width, _, err := term.GetSize(int(os.Stdout.Fd())) width, _, err := term.GetSize(int(os.Stdout.Fd()))
width = max(20, width-70)
if err != nil { if err != nil {
return return
} }
@ -1923,9 +1929,10 @@ func (c *Client) setBar() {
if err != nil { if err != nil {
return return
} }
width = max(20, width-70)
description = strings.TrimSpace(description) description = strings.TrimSpace(description)
if len(description) > width { if len(description) > width {
description = description[:(width-3)] + "..." description = description[:width-3] + "..."
} }
c.bar = progressbar.NewOptions64( c.bar = progressbar.NewOptions64(
c.FilesToTransfer[c.FilesToTransferCurrentNum].Size, c.FilesToTransfer[c.FilesToTransferCurrentNum].Size,