github.com/TrueBlocks/trueblocks-core/src/apps/chifra@v0.0.0-20241022031540-b362680128f7/internal/scrape/scrape_chunk_notify.go (about) 1 package scrapePkg 2 3 import ( 4 "github.com/TrueBlocks/trueblocks-core/src/apps/chifra/pkg/base" 5 "github.com/TrueBlocks/trueblocks-core/src/apps/chifra/pkg/config" 6 "github.com/TrueBlocks/trueblocks-core/src/apps/chifra/pkg/index" 7 "github.com/TrueBlocks/trueblocks-core/src/apps/chifra/pkg/notify" 8 ) 9 10 func (opts *ScrapeOptions) NotifyChunkWritten(chunk index.Chunk, chunkPath string) (err error) { 11 if !opts.Notify { 12 return nil 13 } 14 15 // If --notify is on, it's properly configured and IPFS is running 16 var cidString string 17 if config.IpfsRunning() { // probablyh redundant 18 if cidString, err = index.ChunkCid(chunkPath); err != nil { 19 return err 20 } 21 } 22 23 // Generate range from path, as chunks sometimes don't have Range set 24 chunkRange := base.RangeFromFilename(index.ToIndexPath(chunkPath)) 25 return Notify(notify.Notification[[]notify.NotificationPayloadChunkWritten]{ 26 Msg: notify.MessageChunkWritten, 27 Meta: nil, 28 Payload: []notify.NotificationPayloadChunkWritten{ 29 { 30 Cid: cidString, 31 Range: chunkRange.String(), 32 Author: config.GetRootConfig().Settings.Notify.Author, 33 }, 34 }, 35 }) 36 }