tangled
alpha
login
or
join now
atscan.net
/
plcbundle
A Transparent and Verifiable Way to Sync the AT Protocol's PLC Directory
14
fork
atom
overview
issues
2
pulls
pipelines
update verification
tree.fail
3 months ago
9da01487
2024fe0f
+35
-5
1 changed file
expand all
collapse all
unified
split
bundle
manager.go
+35
-5
bundle/manager.go
···
619
return result, nil
620
}
621
622
-
// Verify hash
623
-
valid, actualHash, err := m.operations.VerifyHash(path, meta.CompressedHash)
624
if err != nil {
625
result.Error = err
626
return result, nil
627
}
628
629
-
result.LocalHash = actualHash
630
-
result.HashMatch = valid
631
-
result.Valid = valid
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
632
633
return result, nil
634
}
···
619
return result, nil
620
}
621
622
+
// Verify BOTH compressed and content hashes
623
+
compHash, compSize, contentHash, contentSize, err := m.operations.CalculateFileHashes(path)
624
if err != nil {
625
result.Error = err
626
return result, nil
627
}
628
629
+
result.LocalHash = compHash
630
+
631
+
// Verify compressed hash
632
+
if compHash != meta.CompressedHash {
633
+
result.HashMatch = false
634
+
result.Valid = false
635
+
result.Error = fmt.Errorf("compressed hash mismatch: expected %s, got %s", meta.CompressedHash, compHash)
636
+
return result, nil
637
+
}
638
+
639
+
// Verify content hash
640
+
if contentHash != meta.ContentHash {
641
+
result.HashMatch = false
642
+
result.Valid = false
643
+
result.Error = fmt.Errorf("content hash mismatch: expected %s, got %s", meta.ContentHash, contentHash)
644
+
return result, nil
645
+
}
646
+
647
+
// Verify sizes match
648
+
if compSize != meta.CompressedSize {
649
+
result.Valid = false
650
+
result.Error = fmt.Errorf("compressed size mismatch: expected %d, got %d", meta.CompressedSize, compSize)
651
+
return result, nil
652
+
}
653
+
654
+
if contentSize != meta.UncompressedSize {
655
+
result.Valid = false
656
+
result.Error = fmt.Errorf("uncompressed size mismatch: expected %d, got %d", meta.UncompressedSize, contentSize)
657
+
return result, nil
658
+
}
659
+
660
+
result.HashMatch = true
661
+
result.Valid = true
662
663
return result, nil
664
}