Setup de la règle SendErrorRule

This commit is contained in:
Benjamin 2022-03-15 20:27:49 +01:00
parent 4a2a84b874
commit 43844c9b54
4 changed files with 10 additions and 7 deletions

View File

@ -44,7 +44,7 @@ func main() {
protocolRepository.AddWriter(&sendOkRule) protocolRepository.AddWriter(&sendOkRule)
// Creation of the SendErrorRule // Creation of the SendErrorRule
sendErrorRule := writers.CreateSendOkRule("^SEND_ERROR\r\n$") sendErrorRule := writers.CreateSendErrorRule("^SEND_ERROR\r\n$")
protocolRepository.AddWriter(&sendErrorRule) protocolRepository.AddWriter(&sendErrorRule)
// Creation of the EraseOkRule // Creation of the EraseOkRule

View File

@ -65,12 +65,14 @@ func (rule SendFileRule) onRead(fileName string, fileSize int, fingerPrint strin
return func(reader *bufio.Reader) *protocol.ProtocolWriterResult { return func(reader *bufio.Reader) *protocol.ProtocolWriterResult {
path := fmt.Sprintf("%s/%s", rule.storagePath, fileName) path := fmt.Sprintf("%s/%s", rule.storagePath, fileName)
if utils.ReceiveFile(path, fileSize, reader) { if utils.ReceiveFile(path, fileSize, reader) {
hashCompare, err := utils.HashFileCompare(path, fingerPrint) hashCompare, err := utils.HashFileCompare(path, fingerPrint)
if err == nil && hashCompare { if err == nil && hashCompare {
return rule.protocolRepo.ExecuteWriter(writers.SendOkRulePrefix) return rule.protocolRepo.ExecuteWriter(writers.SendOkRulePrefix)
} }
} }
os.Remove(path) os.Remove(path)
return rule.protocolRepo.ExecuteWriter(writers.SendErrorRulePrefix) return rule.protocolRepo.ExecuteWriter(writers.SendErrorRulePrefix)
} }

View File

@ -45,6 +45,7 @@ func HashFileCompare(filePath string, fingerprint string) (bool, error) {
if err != nil { if err != nil {
return false, err return false, err
} }
println("OKOK ", fileFingerprint, fingerprint)
if strings.Compare(fileFingerprint, fingerprint) == 0 { if strings.Compare(fileFingerprint, fingerprint) == 0 {
return true, nil return true, nil
} }

View File

@ -1,8 +1,8 @@
{ {
"multicastNetworkInterface": "Loopback Pseudo-Interface 1", "multicastNetworkInterface" : "wlp1s0",
"multicastAddress" : "224.66.66.1:15502", "multicastAddress" : "224.66.66.1:15502",
"multicastSecond" : 30, "multicastSecond" : 30,
"domain": "orglightcont01", "domain" : "lightcontainerSB01",
"unicastPort" : 58000, "unicastPort" : 58000,
"storagePath": "D:\\sbe" "storagePath" : "/home/benjamin/sbe"
} }