check file size firsty

This commit is contained in:
Zack Scholl 2021-04-20 09:08:02 -07:00
parent 91a3dd5866
commit e9949ce3d7
1 changed files with 7 additions and 2 deletions

View File

@ -1236,7 +1236,13 @@ func (c *Client) updateIfRecipientHasFileInfo() (err error) {
if i < c.FilesToTransferCurrentNum {
continue
}
fileHash, errHash := utils.HashFile(path.Join(fileInfo.FolderRemote, fileInfo.Name))
recipientFileInfo, errRecipientFile := os.Lstat(path.Join(fileInfo.FolderRemote, fileInfo.Name))
var errHash error
var fileHash []byte
if errRecipientFile == nil && recipientFileInfo.Size() == fileInfo.Size {
// the file exists, but is same size, so hash it
fileHash, errHash = utils.HashFile(path.Join(fileInfo.FolderRemote, fileInfo.Name))
}
if fileInfo.Size == 0 || fileInfo.Symlink != "" {
err = c.createEmptyFileAndFinish(fileInfo, i)
if err != nil {
@ -1275,7 +1281,6 @@ func (c *Client) updateIfRecipientHasFileInfo() (err error) {
c.LastFolder = newFolder
break
}
// TODO: print out something about this file already existing
}
err = c.recipientGetFileReady(finished)
return