mirror of
https://github.com/schollz/croc.git
synced 2025-10-11 13:21:00 +02:00
reduce complexity
This commit is contained in:
parent
4e94a22300
commit
ae81dd9a7b
1 changed files with 37 additions and 29 deletions
|
@ -798,24 +798,7 @@ func (c *Client) recipientGetFileReady(finished bool) (err error) {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
func (c *Client) updateIfRecipientHasFileInfo() (err error) {
|
func (c *Client) createEmptyFileAndFinish(fileInfo FileInfo, i int) (err error) {
|
||||||
if !(!c.Options.IsSender && c.Step2FileInfoTransfered && !c.Step3RecipientRequestFile) {
|
|
||||||
return
|
|
||||||
}
|
|
||||||
// find the next file to transfer and send that number
|
|
||||||
// if the files are the same size, then look for missing chunks
|
|
||||||
finished := true
|
|
||||||
|
|
||||||
for i, fileInfo := range c.FilesToTransfer {
|
|
||||||
if _, ok := c.FilesHasFinished[i]; ok {
|
|
||||||
continue
|
|
||||||
}
|
|
||||||
log.Debugf("checking %+v", fileInfo)
|
|
||||||
if i < c.FilesToTransferCurrentNum {
|
|
||||||
continue
|
|
||||||
}
|
|
||||||
fileHash, errHash := utils.HashFile(path.Join(fileInfo.FolderRemote, fileInfo.Name))
|
|
||||||
if fileInfo.Size == 0 {
|
|
||||||
log.Debugf("touching file with folder / name")
|
log.Debugf("touching file with folder / name")
|
||||||
if !utils.Exists(fileInfo.FolderRemote) {
|
if !utils.Exists(fileInfo.FolderRemote) {
|
||||||
err = os.MkdirAll(fileInfo.FolderRemote, os.ModePerm)
|
err = os.MkdirAll(fileInfo.FolderRemote, os.ModePerm)
|
||||||
|
@ -847,6 +830,31 @@ func (c *Client) updateIfRecipientHasFileInfo() (err error) {
|
||||||
progressbar.OptionSetWriter(os.Stderr),
|
progressbar.OptionSetWriter(os.Stderr),
|
||||||
)
|
)
|
||||||
c.bar.Finish()
|
c.bar.Finish()
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
func (c *Client) updateIfRecipientHasFileInfo() (err error) {
|
||||||
|
if !(!c.Options.IsSender && c.Step2FileInfoTransfered && !c.Step3RecipientRequestFile) {
|
||||||
|
return
|
||||||
|
}
|
||||||
|
// find the next file to transfer and send that number
|
||||||
|
// if the files are the same size, then look for missing chunks
|
||||||
|
finished := true
|
||||||
|
|
||||||
|
for i, fileInfo := range c.FilesToTransfer {
|
||||||
|
if _, ok := c.FilesHasFinished[i]; ok {
|
||||||
|
continue
|
||||||
|
}
|
||||||
|
log.Debugf("checking %+v", fileInfo)
|
||||||
|
if i < c.FilesToTransferCurrentNum {
|
||||||
|
continue
|
||||||
|
}
|
||||||
|
fileHash, errHash := utils.HashFile(path.Join(fileInfo.FolderRemote, fileInfo.Name))
|
||||||
|
if fileInfo.Size == 0 {
|
||||||
|
err = c.createEmptyFileAndFinish(fileInfo, i)
|
||||||
|
if err != nil {
|
||||||
|
return
|
||||||
|
}
|
||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
log.Debugf("%s %+x %+x %+v", fileInfo.Name, fileHash, fileInfo.Hash, errHash)
|
log.Debugf("%s %+x %+x %+v", fileInfo.Name, fileHash, fileInfo.Hash, errHash)
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue