mirror of
https://github.com/schollz/croc.git
synced 2025-10-11 13:21:00 +02:00
skip checking each file each time
This commit is contained in:
parent
7515c92a8b
commit
4150feddf0
1 changed files with 6 additions and 0 deletions
|
@ -72,6 +72,7 @@ type Client struct {
|
||||||
// send / receive information of all files
|
// send / receive information of all files
|
||||||
FilesToTransfer []FileInfo
|
FilesToTransfer []FileInfo
|
||||||
FilesToTransferCurrentNum int
|
FilesToTransferCurrentNum int
|
||||||
|
FilesHasFinished map[int]struct{}
|
||||||
|
|
||||||
// send / receive information of current file
|
// send / receive information of current file
|
||||||
CurrentFile *os.File
|
CurrentFile *os.File
|
||||||
|
@ -121,6 +122,7 @@ type SenderInfo struct {
|
||||||
// New establishes a new connection for transfering files between two instances.
|
// New establishes a new connection for transfering files between two instances.
|
||||||
func New(ops Options) (c *Client, err error) {
|
func New(ops Options) (c *Client, err error) {
|
||||||
c = new(Client)
|
c = new(Client)
|
||||||
|
c.FilesHasFinished = make(map[int]struct{})
|
||||||
|
|
||||||
// setup basic info
|
// setup basic info
|
||||||
c.Options = ops
|
c.Options = ops
|
||||||
|
@ -667,6 +669,9 @@ func (c *Client) updateState() (err error) {
|
||||||
finished := true
|
finished := true
|
||||||
|
|
||||||
for i, fileInfo := range c.FilesToTransfer {
|
for i, fileInfo := range c.FilesToTransfer {
|
||||||
|
if _, ok := c.FilesHasFinished[i]; ok {
|
||||||
|
continue
|
||||||
|
}
|
||||||
log.Debugf("checking %+v", fileInfo)
|
log.Debugf("checking %+v", fileInfo)
|
||||||
if i < c.FilesToTransferCurrentNum {
|
if i < c.FilesToTransferCurrentNum {
|
||||||
continue
|
continue
|
||||||
|
@ -733,6 +738,7 @@ func (c *Client) updateState() (err error) {
|
||||||
panic(err)
|
panic(err)
|
||||||
}
|
}
|
||||||
c.SuccessfulTransfer = true
|
c.SuccessfulTransfer = true
|
||||||
|
c.FilesHasFinished[c.FilesToTransferCurrentNum] = struct{}{}
|
||||||
}
|
}
|
||||||
|
|
||||||
// start initiating the process to receive a new file
|
// start initiating the process to receive a new file
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue