diff --git a/cmd/main.go b/cmd/main.go index 770cff3..0045f6e 100644 --- a/cmd/main.go +++ b/cmd/main.go @@ -44,7 +44,7 @@ func main() { protocolRepository.AddWriter(&sendOkRule) // Creation of the SendErrorRule - sendErrorRule := writers.CreateSendOkRule("^SEND_ERROR\r\n$") + sendErrorRule := writers.CreateSendErrorRule("^SEND_ERROR\r\n$") protocolRepository.AddWriter(&sendErrorRule) // Creation of the EraseOkRule diff --git a/pkg/protocol/rules/readers/SendFileRule.go b/pkg/protocol/rules/readers/SendFileRule.go index 5669350..b9e7113 100644 --- a/pkg/protocol/rules/readers/SendFileRule.go +++ b/pkg/protocol/rules/readers/SendFileRule.go @@ -65,12 +65,14 @@ func (rule SendFileRule) onRead(fileName string, fileSize int, fingerPrint strin return func(reader *bufio.Reader) *protocol.ProtocolWriterResult { path := fmt.Sprintf("%s/%s", rule.storagePath, fileName) + if utils.ReceiveFile(path, fileSize, reader) { hashCompare, err := utils.HashFileCompare(path, fingerPrint) if err == nil && hashCompare { return rule.protocolRepo.ExecuteWriter(writers.SendOkRulePrefix) } } + os.Remove(path) return rule.protocolRepo.ExecuteWriter(writers.SendErrorRulePrefix) } diff --git a/pkg/utils/SHA.go b/pkg/utils/SHA.go index 80fe877..87c2096 100644 --- a/pkg/utils/SHA.go +++ b/pkg/utils/SHA.go @@ -45,6 +45,7 @@ func HashFileCompare(filePath string, fingerprint string) (bool, error) { if err != nil { return false, err } + println("OKOK ", fileFingerprint, fingerprint) if strings.Compare(fileFingerprint, fingerprint) == 0 { return true, nil } diff --git a/resources/AppConfig.json b/resources/AppConfig.json index 035cc65..0fe2c77 100644 --- a/resources/AppConfig.json +++ b/resources/AppConfig.json @@ -1,8 +1,8 @@ { - "multicastNetworkInterface": "Loopback Pseudo-Interface 1", - "multicastAddress": "224.66.66.1:15502", - "multicastSecond": 30, - "domain": "orglightcont01", - "unicastPort": 58000, - "storagePath": "D:\\sbe" + "multicastNetworkInterface" : "wlp1s0", + "multicastAddress" : "224.66.66.1:15502", + "multicastSecond" : 30, + "domain" : "lightcontainerSB01", + "unicastPort" : 58000, + "storagePath" : "/home/benjamin/sbe" } \ No newline at end of file