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-07-12 14:45:22 +08:00
|
|
|
Get(metainfo.Piece) (bool, error)
|
|
|
|
Set(metainfo.Piece, 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
|
|
|
|
}
|