Skip to content

Commit

Permalink
err handling
Browse files Browse the repository at this point in the history
  • Loading branch information
stevemilk committed Oct 10, 2024
1 parent 56fe30b commit 3b57924
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 4 deletions.
2 changes: 1 addition & 1 deletion erigon-lib/downloader/downloader.go
Original file line number Diff line number Diff line change
Expand Up @@ -2976,7 +2976,7 @@ func (d *Downloader) torrentCompleted(tName string, tHash metainfo.Hash) {
}

// create commitment file for .seg/.idx files
if !strings.HasSuffix(tName, ".seg") || !strings.HasSuffix(tName, ".idx") {
if !strings.HasSuffix(tName, ".seg") && !strings.HasSuffix(tName, ".idx") {
return
}
tName = strings.ReplaceAll(tName, ".seg", ".txt")
Expand Down
14 changes: 11 additions & 3 deletions turbo/snapshotsync/freezeblocks/block_snapshots.go
Original file line number Diff line number Diff line change
Expand Up @@ -757,19 +757,27 @@ func (s *RoSnapshots) integrityCheck(fName string) bool {
func integrityCheck(dir, fName string) bool {
file := filepath.Join(dir, fName)
f, err := os.Stat(file)
if os.IsNotExist(err) {
if err != nil {
log.Warn("[snapshots] integrityCheck", "err", err)
return false
}
torrentFile := filepath.Join(dir, fName) + ".torrent"
if _, err := os.Stat(torrentFile); os.IsNotExist(err) {
_, err = os.Stat(torrentFile)
if err != nil {
if !os.IsNotExist(err) {
log.Warn("[snapshots] integrityCheck", "err", err)
}
// torrent file not exists means that file is created locally, in this case file must be complete
return true
}
fName = strings.ReplaceAll(fName, ".seg", ".txt")
fName = strings.ReplaceAll(fName, ".idx", ".txt")
commitmentFile := filepath.Join(dir, "commitment", fName)
cf, err := os.Stat(commitmentFile)
if os.IsNotExist(err) {
if err != nil {
if !os.IsNotExist(err) {
log.Warn("[snapshots] integrityCheck", "err", err)
}
return false
}
if cf.ModTime().After(f.ModTime()) {
Expand Down

0 comments on commit 3b57924

Please sign in to comment.