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"
|
|
|
|
)
|
|
|
|
|
|
|
|
type pieceCompletion interface {
|
2016-08-26 18:29:05 +08:00
|
|
|
Get(metainfo.PieceKey) (bool, error)
|
|
|
|
Set(metainfo.PieceKey, bool) error
|
2016-07-06 11:38:16 +08:00
|
|
|
Close()
|
|
|
|
}
|
2016-06-20 15:51:05 +08:00
|
|
|
|
|
|
|
func pieceCompletionForDir(dir string) (ret pieceCompletion) {
|
|
|
|
ret, err := newDBPieceCompletion(dir)
|
|
|
|
if err != nil {
|
|
|
|
log.Printf("couldn't open piece completion db in %q: %s", dir, err)
|
|
|
|
ret = new(mapPieceCompletion)
|
|
|
|
}
|
|
|
|
return
|
|
|
|
}
|