From ad421ea2d0ff16f3be7e2401754d60337fd8e4dc Mon Sep 17 00:00:00 2001 From: Matt Joiner Date: Fri, 14 May 2021 15:51:26 +1000 Subject: [PATCH] Default to sqlite piece completion for dir if cgo enabled --- storage/default-dir-piece-completion-boltdb.go | 8 ++++++++ storage/default-dir-piece-completion-sqlite.go | 8 ++++++++ storage/piece-completion.go | 2 +- 3 files changed, 17 insertions(+), 1 deletion(-) create mode 100644 storage/default-dir-piece-completion-boltdb.go create mode 100644 storage/default-dir-piece-completion-sqlite.go diff --git a/storage/default-dir-piece-completion-boltdb.go b/storage/default-dir-piece-completion-boltdb.go new file mode 100644 index 00000000..5ba587b7 --- /dev/null +++ b/storage/default-dir-piece-completion-boltdb.go @@ -0,0 +1,8 @@ +//go:build !cgo +// +build !cgo + +package storage + +func NewDefaultPieceCompletionForDir(dir string) (PieceCompletion, error) { + return NewBoltPieceCompletion(dir) +} diff --git a/storage/default-dir-piece-completion-sqlite.go b/storage/default-dir-piece-completion-sqlite.go new file mode 100644 index 00000000..7c347956 --- /dev/null +++ b/storage/default-dir-piece-completion-sqlite.go @@ -0,0 +1,8 @@ +//go:build cgo +// +build cgo + +package storage + +func NewDefaultPieceCompletionForDir(dir string) (PieceCompletion, error) { + return NewSqlitePieceCompletion(dir) +} diff --git a/storage/piece-completion.go b/storage/piece-completion.go index 791fce60..bc646bd7 100644 --- a/storage/piece-completion.go +++ b/storage/piece-completion.go @@ -18,7 +18,7 @@ type PieceCompletion interface { } func pieceCompletionForDir(dir string) (ret PieceCompletion) { - ret, err := NewBoltPieceCompletion(dir) + ret, err := NewDefaultPieceCompletionForDir(dir) if err != nil { log.Printf("couldn't open piece completion db in %q: %s", dir, err) ret = NewMapPieceCompletion()