MCPcopy
hub / github.com/ph4ntonn/Stowaway / DispatchFileMess

Function DispatchFileMess

agent/handler/file.go:9–37  ·  view source on GitHub ↗
(mgr *manager.Manager)

Source from the content-addressed store, hash-verified

7)
8
9func DispatchFileMess(mgr *manager.Manager) {
10 for {
11 message := <-mgr.FileManager.FileMessChan
12
13 switch mess := message.(type) {
14 case *protocol.FileStatReq:
15 mgr.FileManager.File.FileName = mess.Filename
16 mgr.FileManager.File.SliceNum = mess.SliceNum
17 err := mgr.FileManager.File.CheckFileStat(protocol.TEMP_ROUTE, protocol.ADMIN_UUID, share.AGENT)
18 if err == nil {
19 go mgr.FileManager.File.Receive(protocol.TEMP_ROUTE, protocol.ADMIN_UUID, share.AGENT)
20 }
21 case *protocol.FileStatRes:
22 if mess.OK == 1 {
23 go mgr.FileManager.File.Upload(protocol.TEMP_ROUTE, protocol.ADMIN_UUID, share.AGENT)
24 } else {
25 mgr.FileManager.File.Handler.Close()
26 }
27 case *protocol.FileDownReq:
28 mgr.FileManager.File.FilePath = mess.FilePath
29 mgr.FileManager.File.FileName = mess.Filename
30 go mgr.FileManager.File.SendFileStat(protocol.TEMP_ROUTE, protocol.ADMIN_UUID, share.AGENT)
31 case *protocol.FileData:
32 mgr.FileManager.File.DataChan <- mess.Data
33 case *protocol.FileErr:
34 mgr.FileManager.File.ErrChan <- true
35 }
36 }
37}

Callers 1

RunMethod · 0.92

Calls 4

CheckFileStatMethod · 0.80
ReceiveMethod · 0.80
UploadMethod · 0.80
SendFileStatMethod · 0.80

Tested by

no test coverage detected