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
619
return result, nil
620
620
}
621
621
622
622
-
// Verify hash
623
623
-
valid, actualHash, err := m.operations.VerifyHash(path, meta.CompressedHash)
622
622
+
// Verify BOTH compressed and content hashes
623
623
+
compHash, compSize, contentHash, contentSize, err := m.operations.CalculateFileHashes(path)
624
624
if err != nil {
625
625
result.Error = err
626
626
return result, nil
627
627
}
628
628
629
629
-
result.LocalHash = actualHash
630
630
-
result.HashMatch = valid
631
631
-
result.Valid = valid
629
629
+
result.LocalHash = compHash
630
630
+
631
631
+
// Verify compressed hash
632
632
+
if compHash != meta.CompressedHash {
633
633
+
result.HashMatch = false
634
634
+
result.Valid = false
635
635
+
result.Error = fmt.Errorf("compressed hash mismatch: expected %s, got %s", meta.CompressedHash, compHash)
636
636
+
return result, nil
637
637
+
}
638
638
+
639
639
+
// Verify content hash
640
640
+
if contentHash != meta.ContentHash {
641
641
+
result.HashMatch = false
642
642
+
result.Valid = false
643
643
+
result.Error = fmt.Errorf("content hash mismatch: expected %s, got %s", meta.ContentHash, contentHash)
644
644
+
return result, nil
645
645
+
}
646
646
+
647
647
+
// Verify sizes match
648
648
+
if compSize != meta.CompressedSize {
649
649
+
result.Valid = false
650
650
+
result.Error = fmt.Errorf("compressed size mismatch: expected %d, got %d", meta.CompressedSize, compSize)
651
651
+
return result, nil
652
652
+
}
653
653
+
654
654
+
if contentSize != meta.UncompressedSize {
655
655
+
result.Valid = false
656
656
+
result.Error = fmt.Errorf("uncompressed size mismatch: expected %d, got %d", meta.UncompressedSize, contentSize)
657
657
+
return result, nil
658
658
+
}
659
659
+
660
660
+
result.HashMatch = true
661
661
+
result.Valid = true
632
662
633
663
return result, nil
634
664
}