mirror of
https://github.com/schollz/croc.git
synced 2025-10-11 13:21:00 +02:00
use single reader
This commit is contained in:
parent
cce4a7ed92
commit
98799d057f
1 changed files with 2 additions and 17 deletions
|
@ -30,7 +30,6 @@ import (
|
||||||
"github.com/schollz/peerdiscovery"
|
"github.com/schollz/peerdiscovery"
|
||||||
"github.com/schollz/progressbar/v2"
|
"github.com/schollz/progressbar/v2"
|
||||||
"github.com/schollz/spinner"
|
"github.com/schollz/spinner"
|
||||||
"golang.org/x/exp/mmap"
|
|
||||||
)
|
)
|
||||||
|
|
||||||
func init() {
|
func init() {
|
||||||
|
@ -92,7 +91,7 @@ type Client struct {
|
||||||
firstSend bool
|
firstSend bool
|
||||||
|
|
||||||
mutex *sync.Mutex
|
mutex *sync.Mutex
|
||||||
fread *mmap.ReaderAt
|
fread *os.File
|
||||||
numfinished int
|
numfinished int
|
||||||
quit chan bool
|
quit chan bool
|
||||||
}
|
}
|
||||||
|
@ -851,7 +850,7 @@ func (c *Client) updateState() (err error) {
|
||||||
c.FilesToTransfer[c.FilesToTransferCurrentNum].Name,
|
c.FilesToTransfer[c.FilesToTransferCurrentNum].Name,
|
||||||
)
|
)
|
||||||
|
|
||||||
c.fread, err = mmap.Open(pathToFile)
|
c.fread, err = os.Open(pathToFile)
|
||||||
c.numfinished = 0
|
c.numfinished = 0
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return
|
return
|
||||||
|
@ -958,16 +957,6 @@ func (c *Client) sendData(i int) {
|
||||||
c.fread.Close()
|
c.fread.Close()
|
||||||
}
|
}
|
||||||
}()
|
}()
|
||||||
// pathToFile := path.Join(
|
|
||||||
// c.FilesToTransfer[c.FilesToTransferCurrentNum].FolderSource,
|
|
||||||
// c.FilesToTransfer[c.FilesToTransferCurrentNum].Name,
|
|
||||||
// )
|
|
||||||
// log.Debugf("opening %s to read", pathToFile)
|
|
||||||
// f, err := mmap.Open(pathToFile)
|
|
||||||
// if err != nil {
|
|
||||||
// panic(err)
|
|
||||||
// }
|
|
||||||
// defer f.Close()
|
|
||||||
|
|
||||||
var readingPos int64
|
var readingPos int64
|
||||||
pos := uint64(0)
|
pos := uint64(0)
|
||||||
|
@ -1006,9 +995,7 @@ func (c *Client) sendData(i int) {
|
||||||
panic(err)
|
panic(err)
|
||||||
}
|
}
|
||||||
|
|
||||||
log.Debug("sending data")
|
|
||||||
err = c.conn[i+1].Send(dataToSend)
|
err = c.conn[i+1].Send(dataToSend)
|
||||||
log.Debug("sent")
|
|
||||||
if err != nil {
|
if err != nil {
|
||||||
panic(err)
|
panic(err)
|
||||||
}
|
}
|
||||||
|
@ -1030,7 +1017,5 @@ func (c *Client) sendData(i int) {
|
||||||
panic(errRead)
|
panic(errRead)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// time.Sleep(10 * time.Second)
|
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue