Add check subcommand
This commit is contained in:
parent
2ae7687403
commit
7b44dddf5b
|
@ -26,8 +26,11 @@ when defined(readLine):
|
|||
# import ./blobsets/tcp
|
||||
|
||||
proc openStore(): BlobStore =
|
||||
#newFileStore("/tmp/blobs")
|
||||
newHttpStore("http://10.0.1.63/")
|
||||
const key = "BLOB_STORE_URL"
|
||||
let url = os.getEnv key
|
||||
if url == "":
|
||||
quit(key & " not set in environment")
|
||||
newHttpStore(url)
|
||||
|
||||
proc serverMain() =
|
||||
let
|
||||
|
@ -82,6 +85,22 @@ proc ingestMain() =
|
|||
let final = store.commit set
|
||||
writeLine(stdout, final.setId.toHex)
|
||||
|
||||
proc checkMain() =
|
||||
var args = newSeq[string]()
|
||||
for kind, key, val in getopt():
|
||||
if kind == cmdArgument:
|
||||
args.add key
|
||||
if args.len > 1:
|
||||
let store = openStore()
|
||||
for i in 1..args.high:
|
||||
try:
|
||||
let bs = store.load(args[i].toBlobId)
|
||||
store.applyAll(bs, i) do (id: BlobId; size: BiggestInt):
|
||||
close(store.openBlobStream(id, size, dataBlob))
|
||||
except:
|
||||
writeLine(stderr, "failed to check '", args[i], "', ", getCurrentExceptionMsg())
|
||||
quit(-1)
|
||||
|
||||
type
|
||||
EvalError = object of CatchableError
|
||||
|
||||
|
@ -824,6 +843,7 @@ proc main() =
|
|||
of "ingest": ingestMain()
|
||||
of "server": serverMain()
|
||||
of "spry": spryMain()
|
||||
of "check": checkMain()
|
||||
else: quit("no such subcommand ")
|
||||
|
||||
main()
|
||||
|
|
Loading…
Reference in New Issue