From 4796404b7efff98f1697b86d67e18e6c129d11f7 Mon Sep 17 00:00:00 2001 From: Zack Scholl Date: Tue, 15 Jun 2021 14:53:16 -0700 Subject: [PATCH] show resume message if resuming Fixes #402 --- src/croc/croc.go | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/src/croc/croc.go b/src/croc/croc.go index ff936e4..e23323f 100644 --- a/src/croc/croc.go +++ b/src/croc/croc.go @@ -1269,8 +1269,19 @@ func (c *Client) updateIfRecipientHasFileInfo() (err error) { log.Debugf("hashed %s to %x using %s", fileInfo.Name, fileHash, c.Options.HashAlgorithm) log.Debugf("hashes are not equal %x != %x", fileHash, fileInfo.Hash) if errHash == nil && !c.Options.Overwrite && errRecipientFile == nil && !strings.HasPrefix(fileInfo.Name, "croc-stdin-") { + + missingChunks := utils.ChunkRangesToChunks(utils.MissingChunks( + path.Join(fileInfo.FolderRemote, fileInfo.Name), + fileInfo.Size, + models.TCP_BUFFER_SIZE/2, + )) + percentDone := 100 - float64(len(missingChunks)*models.TCP_BUFFER_SIZE/2)/float64(fileInfo.Size)*100 + log.Debug("asking to overwrite") prompt := fmt.Sprintf("\nOverwrite '%s'? (y/N) ", path.Join(fileInfo.FolderRemote, fileInfo.Name)) + if percentDone < 99 { + prompt = fmt.Sprintf("\nResume '%s' (%2.1f%%)? (y/N) ", path.Join(fileInfo.FolderRemote, fileInfo.Name), percentDone) + } choice := strings.ToLower(utils.GetInput(prompt)) if choice != "y" && choice != "yes" { fmt.Fprintf(os.Stderr, "skipping '%s'", path.Join(fileInfo.FolderRemote, fileInfo.Name))