This commit is contained in:
Dmitriy Ryajov 2022-09-20 09:21:41 -06:00
parent a3781edc6a
commit e6430b6b85
No known key found for this signature in database
GPG Key ID: DA8C680CE7C657A4
6 changed files with 8 additions and 31 deletions

View File

@ -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

View File

@ -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

View File

@ -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

View File

@ -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:

View File

@ -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))

View File

@ -1,4 +1,3 @@
import std/algorithm
import std/options
import std/os