2016-06-20 15:51:05 +08:00
|
|
|
package storage
|
|
|
|
|
2016-07-06 11:38:16 +08:00
|
|
|
import (
|
|
|
|
"log"
|
|
|
|
|
|
|
|
"github.com/anacrolix/torrent/metainfo"
|
|
|
|
)
|
|
|
|
|
2016-10-25 16:07:26 +08:00
|
|
|
// Implementations track the completion of pieces.
|
2016-07-06 11:38:16 +08:00
|
|
|
type pieceCompletion interface {
|
2016-08-26 18:29:05 +08:00
|
|
|
Get(metainfo.PieceKey) (bool, error)
|
|
|
|
Set(metainfo.PieceKey, bool) error
|
2016-10-25 16:07:26 +08:00
|
|
|
Close() error
|
2016-07-06 11:38:16 +08:00
|
|
|
}
|
2016-06-20 15:51:05 +08:00
|
|
|
|
|
|
|
func pieceCompletionForDir(dir string) (ret pieceCompletion) {
|
2016-10-25 16:07:26 +08:00
|
|
|
ret, err := newBoltPieceCompletion(dir)
|
2016-06-20 15:51:05 +08:00
|
|
|
if err != nil {
|
|
|
|
log.Printf("couldn't open piece completion db in %q: %s", dir, err)
|
|
|
|
ret = new(mapPieceCompletion)
|
|
|
|
}
|
|
|
|
return
|
|
|
|
}
|