mirror of
https://github.com/schollz/croc.git
synced 2025-10-11 13:21:00 +02:00
works
This commit is contained in:
parent
311c144ebd
commit
ddd0b7ab0a
1 changed files with 19 additions and 5 deletions
|
@ -189,15 +189,17 @@ func (c *Client) transfer(options TransferOptions) (err error) {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
fullPath = filepath.Clean(fullPath)
|
fullPath = filepath.Clean(fullPath)
|
||||||
|
var folderName string
|
||||||
|
folderName, _ = filepath.Split(fullPath)
|
||||||
|
|
||||||
fstats, err = os.Stat(path.Join(fullPath))
|
fstats, err = os.Stat(fullPath)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
c.FilesToTransfer[i] = FileInfo{
|
c.FilesToTransfer[i] = FileInfo{
|
||||||
Name: fstats.Name(),
|
Name: fstats.Name(),
|
||||||
FolderRemote: ".",
|
FolderRemote: ".",
|
||||||
FolderSource: fullPath,
|
FolderSource: folderName,
|
||||||
Size: fstats.Size(),
|
Size: fstats.Size(),
|
||||||
ModTime: fstats.ModTime(),
|
ModTime: fstats.ModTime(),
|
||||||
}
|
}
|
||||||
|
@ -207,8 +209,6 @@ func (c *Client) transfer(options TransferOptions) (err error) {
|
||||||
}
|
}
|
||||||
if options.KeepPathInRemote {
|
if options.KeepPathInRemote {
|
||||||
var curFolder string
|
var curFolder string
|
||||||
folderName, _ := filepath.Split(fullPath)
|
|
||||||
|
|
||||||
curFolder, err = os.Getwd()
|
curFolder, err = os.Getwd()
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return
|
return
|
||||||
|
@ -378,6 +378,12 @@ func (c *Client) processMessage(m Message) (err error) {
|
||||||
answer := util.Decode(m.Message)
|
answer := util.Decode(m.Message)
|
||||||
// Apply the answer as the remote description
|
// Apply the answer as the remote description
|
||||||
err = c.peerConnection.SetRemoteDescription(answer)
|
err = c.peerConnection.SetRemoteDescription(answer)
|
||||||
|
case "finished-transfer":
|
||||||
|
c.Step3RecipientRequestFile = false
|
||||||
|
c.Step4FileTransfer = false
|
||||||
|
err = c.redisdb.Publish(c.nameOutChannel, Message{
|
||||||
|
Type: "thanks",
|
||||||
|
}.String()).Err()
|
||||||
}
|
}
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return
|
return
|
||||||
|
@ -548,7 +554,15 @@ func (c *Client) dataChannelReceive() (err error) {
|
||||||
if bytes.Equal(p.Data, []byte("done")) {
|
if bytes.Equal(p.Data, []byte("done")) {
|
||||||
c.CurrentFile.Close()
|
c.CurrentFile.Close()
|
||||||
c.log.Debug(time.Since(timer))
|
c.log.Debug(time.Since(timer))
|
||||||
// TODO: handle done, close file, reset things and check for missing blocks
|
c.log.Debug("telling transfer is over")
|
||||||
|
c.Step4FileTransfer = false
|
||||||
|
c.Step3RecipientRequestFile = false
|
||||||
|
err = c.redisdb.Publish(c.nameOutChannel, Message{
|
||||||
|
Type: "finished-transfer",
|
||||||
|
}.String()).Err()
|
||||||
|
if err != nil {
|
||||||
|
panic(err)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
case *datachannel.PayloadBinary:
|
case *datachannel.PayloadBinary:
|
||||||
if !startTime {
|
if !startTime {
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue