X-Git-Url: http://www.git.cypherpunks.ru/?p=nncp.git;a=blobdiff_plain;f=src%2Fcypherpunks.ru%2Fnncp%2Fsp.go;h=f6b07ce5ad7dac0ac1f6d7ab04f28bab4ae9a5b8;hp=5bffe28d306f6d37301ede3ff433926f54293ae2;hb=7edc3ed722c8d36e4a99b1cf45f209a973165a37;hpb=be9f7118dc750c69e6e0466f42d2da422ea80401 diff --git a/src/cypherpunks.ru/nncp/sp.go b/src/cypherpunks.ru/nncp/sp.go index 5bffe28..f6b07ce 100644 --- a/src/cypherpunks.ru/nncp/sp.go +++ b/src/cypherpunks.ru/nncp/sp.go @@ -763,22 +763,23 @@ func (state *SPState) ProcessSP(payload []byte) ([][]byte, error) { state.infosTheir[*info.Hash] = &info state.Unlock() state.ctx.LogD("sp-process", sdsp, "stating part") - if _, err = os.Stat(filepath.Join( + pktPath := filepath.Join( state.ctx.Spool, state.Node.Id.String(), string(TRx), ToBase32(info.Hash[:]), - )); err == nil { + ) + if _, err = os.Stat(pktPath); err == nil { state.ctx.LogD("sp-process", sdsp, "already done") replies = append(replies, MarshalSP(SPTypeDone, SPDone{info.Hash})) continue } - fi, err := os.Stat(filepath.Join( - state.ctx.Spool, - state.Node.Id.String(), - string(TRx), - ToBase32(info.Hash[:])+PartSuffix, - )) + if _, err = os.Stat(pktPath + SeenSuffix); err == nil { + state.ctx.LogD("sp-process", sdsp, "already seen") + replies = append(replies, MarshalSP(SPTypeDone, SPDone{info.Hash})) + continue + } + fi, err := os.Stat(pktPath + PartSuffix) var offset int64 if err == nil { offset = fi.Size()