mirror of https://github.com/schollz/croc.git
reduce complexity
This commit is contained in:
parent
4e94a22300
commit
ae81dd9a7b
|
@ -798,24 +798,7 @@ func (c *Client) recipientGetFileReady(finished bool) (err error) {
|
|||
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 {
|
||||
func (c *Client) createEmptyFileAndFinish(fileInfo FileInfo, i int) (err error) {
|
||||
log.Debugf("touching file with folder / name")
|
||||
if !utils.Exists(fileInfo.FolderRemote) {
|
||||
err = os.MkdirAll(fileInfo.FolderRemote, os.ModePerm)
|
||||
|
@ -847,6 +830,31 @@ func (c *Client) updateIfRecipientHasFileInfo() (err error) {
|
|||
progressbar.OptionSetWriter(os.Stderr),
|
||||
)
|
||||
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
|
||||
}
|
||||
log.Debugf("%s %+x %+x %+v", fileInfo.Name, fileHash, fileInfo.Hash, errHash)
|
||||
|
|
Loading…
Reference in New Issue