mirror of
https://gitlab.com/pulsechaincom/erigon-pulse.git
synced 2024-12-22 03:30:37 +00:00
fix LoadFromFile empty error (#8877)
This commit is contained in:
parent
b5640bb64b
commit
421118378a
@ -485,11 +485,11 @@ func (d *Downloader) AddNewSeedableFile(ctx context.Context, name string) error
|
||||
// if we don't have the torrent file we build it if we have the .seg file
|
||||
torrentFilePath, err := BuildTorrentIfNeed(ctx, name, d.SnapDir())
|
||||
if err != nil {
|
||||
return err
|
||||
return fmt.Errorf("AddNewSeedableFile: %w", err)
|
||||
}
|
||||
ts, err := loadTorrent(torrentFilePath)
|
||||
if err != nil {
|
||||
return err
|
||||
return fmt.Errorf("AddNewSeedableFile: %w", err)
|
||||
}
|
||||
err = addTorrentFile(ctx, ts, d.torrentClient, d.webseeds)
|
||||
if err != nil {
|
||||
|
@ -155,10 +155,10 @@ func BuildTorrentIfNeed(ctx context.Context, fName, root string) (torrentFilePat
|
||||
|
||||
fPath := filepath.Join(root, fName)
|
||||
if dir2.FileExist(fPath + ".torrent") {
|
||||
return
|
||||
return fPath, nil
|
||||
}
|
||||
if !dir2.FileExist(fPath) {
|
||||
return
|
||||
return fPath, nil
|
||||
}
|
||||
|
||||
info := &metainfo.Info{PieceLength: downloadercfg.DefaultPieceSize, Name: fName}
|
||||
@ -281,9 +281,12 @@ func AllTorrentSpecs(dirs datadir.Dirs) (res []*torrent.TorrentSpec, err error)
|
||||
return nil, err
|
||||
}
|
||||
for _, fPath := range files {
|
||||
if len(fPath) == 0 {
|
||||
continue
|
||||
}
|
||||
a, err := loadTorrent(fPath)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
return nil, fmt.Errorf("AllTorrentSpecs: %w", err)
|
||||
}
|
||||
res = append(res, a)
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user