diff --git a/storage/default-dir-piece-completion-boltdb.go b/storage/default-dir-piece-completion-boltdb.go new file mode 100644 index 00000000..a1e869a2 --- /dev/null +++ b/storage/default-dir-piece-completion-boltdb.go @@ -0,0 +1,11 @@ +// Bolt piece completion is available, and sqlite is not. +//go:build !noboltdb && !wasm && (js || nosqlite) +// +build !noboltdb +// +build !wasm +// +build js nosqlite + +package storage + +func NewDefaultPieceCompletionForDir(dir string) (PieceCompletion, error) { + return NewBoltPieceCompletion(dir) +} diff --git a/storage/default-dir-piece-completion-other.go b/storage/default-dir-piece-completion-other.go index 4e40e397..b6f561ca 100644 --- a/storage/default-dir-piece-completion-other.go +++ b/storage/default-dir-piece-completion-other.go @@ -1,5 +1,6 @@ -//go:build wasm -// +build wasm +// Bolt piece completion is not available, and neither is sqlite. +//go:build wasm || noboltdb +// +build wasm noboltdb package storage diff --git a/storage/default-dir-piece-completion-sqlite.go b/storage/default-dir-piece-completion-sqlite.go deleted file mode 100644 index 8f4fbd4c..00000000 --- a/storage/default-dir-piece-completion-sqlite.go +++ /dev/null @@ -1,8 +0,0 @@ -//go:build !nosqlite -// +build !nosqlite - -package storage - -func NewDefaultPieceCompletionForDir(dir string) (PieceCompletion, error) { - return NewSqlitePieceCompletion(dir) -} diff --git a/storage/sqlite-piece-completion.go b/storage/sqlite-piece-completion.go index 54331e32..30c8a388 100644 --- a/storage/sqlite-piece-completion.go +++ b/storage/sqlite-piece-completion.go @@ -1,5 +1,7 @@ -//go:build !nosqlite -// +build !nosqlite +// modernc.org/sqlite depends on modernc.org/libc which doesn't work for JS (and probably wasm but I +// think JS is the stronger signal). +//go:build !js && !nosqlite +// +build !js,!nosqlite package storage @@ -13,6 +15,11 @@ import ( "zombiezen.com/go/sqlite/sqlitex" ) +// sqlite is always the default when available. +func NewDefaultPieceCompletionForDir(dir string) (PieceCompletion, error) { + return NewSqlitePieceCompletion(dir) +} + type sqlitePieceCompletion struct { mu sync.Mutex closed bool