close db
This commit is contained in:
parent
a3781edc6a
commit
e6430b6b85
|
@ -1,6 +1,4 @@
|
|||
import std/os
|
||||
import std/sequtils
|
||||
import std/strutils
|
||||
import std/options
|
||||
|
||||
import pkg/chronos
|
||||
|
@ -15,27 +13,6 @@ export datastore
|
|||
|
||||
push: {.upraises: [].}
|
||||
|
||||
const
|
||||
# TODO: Add more dirs from relevant OSs
|
||||
|
||||
# Paths should be matched exactly, i.e.
|
||||
# we're forbidding this dirs from being
|
||||
# touched directly, but subdirectories
|
||||
# can still be touched/created
|
||||
ProtectedPaths* =
|
||||
when doslikeFileSystem:
|
||||
[
|
||||
"\\System32",
|
||||
"\\System",
|
||||
"\\Start Menu\\Programs"]
|
||||
else:
|
||||
[
|
||||
"/",
|
||||
"/usr",
|
||||
"/etc",
|
||||
"/home",
|
||||
"/Users"]
|
||||
|
||||
type
|
||||
FSDatastore* = ref object of Datastore
|
||||
root*: string
|
||||
|
|
|
@ -1,11 +1,9 @@
|
|||
import std/os
|
||||
import std/times
|
||||
|
||||
import pkg/chronos
|
||||
import pkg/questionable
|
||||
import pkg/questionable/results
|
||||
import pkg/sqlite3_abi
|
||||
import pkg/stew/byteutils
|
||||
from pkg/stew/results as stewResults import isErr
|
||||
import pkg/upraises
|
||||
|
||||
|
|
|
@ -1,10 +1,8 @@
|
|||
import std/options
|
||||
import std/os
|
||||
|
||||
import pkg/asynctest
|
||||
import pkg/chronos
|
||||
import pkg/stew/results
|
||||
import pkg/stew/byteutils
|
||||
|
||||
import pkg/datastore
|
||||
|
||||
|
|
|
@ -1,4 +1,3 @@
|
|||
import std/algorithm
|
||||
import std/options
|
||||
import std/os
|
||||
|
||||
|
@ -33,9 +32,10 @@ suite "Test Basic SQLiteDatastore":
|
|||
dsDb = SQLiteDatastore.new(path = dbPathAbs).tryGet()
|
||||
|
||||
teardownAll:
|
||||
(await dsDb.close()).tryGet()
|
||||
|
||||
removeDir(basePathAbs)
|
||||
require(not dirExists(basePathAbs))
|
||||
(await dsDb.close()).tryGet()
|
||||
|
||||
basicStoreTests(dsDb, key, bytes, otherBytes)
|
||||
|
||||
|
@ -62,9 +62,11 @@ suite "Test Read Only SQLiteDatastore":
|
|||
readOnlyDb = SQLiteDatastore.new(path = dbPathAbs, readOnly = true).tryGet()
|
||||
|
||||
teardownAll:
|
||||
(await dsDb.close()).tryGet()
|
||||
(await readOnlyDb.close()).tryGet()
|
||||
|
||||
removeDir(basePathAbs)
|
||||
require(not dirExists(basePathAbs))
|
||||
(await dsDb.close()).tryGet()
|
||||
|
||||
test "put":
|
||||
check:
|
||||
|
|
|
@ -101,6 +101,9 @@ suite "Test SQLite Datastore DB operations":
|
|||
flags = SQLITE_OPEN_READONLY).tryGet()
|
||||
|
||||
teardownAll:
|
||||
dsDb.close()
|
||||
readOnlyDb.close()
|
||||
|
||||
removeDir(basePathAbs)
|
||||
require(not dirExists(basePathAbs))
|
||||
|
||||
|
|
|
@ -1,4 +1,3 @@
|
|||
import std/algorithm
|
||||
import std/options
|
||||
import std/os
|
||||
|
||||
|
|
Loading…
Reference in New Issue