From a3e67a17ca7f4c38c5a53aa25aabb2aa713c213a Mon Sep 17 00:00:00 2001 From: poop Date: Wed, 15 Mar 2023 09:52:38 -0700 Subject: [PATCH] fix/valgrind-async-disaptch-threadpool-failure --- src/boat/private/FileManager.nim | 84 ++++++++++++++++---------------- 1 file changed, 42 insertions(+), 42 deletions(-) diff --git a/src/boat/private/FileManager.nim b/src/boat/private/FileManager.nim index eb79e95..b94707b 100644 --- a/src/boat/private/FileManager.nim +++ b/src/boat/private/FileManager.nim @@ -3,12 +3,12 @@ ## =========== ## Saving to and Retrieving from disk -import ../../../bdd +# import ../../../bdd # valgrind throws if this file is imported into ./Config.nim import std/[ asyncdispatch, # causes valgrind to throw - locks, + # locks, threadpool, # causes valgrind to throw ] @@ -16,43 +16,43 @@ import BoatConstants, BoatErrors # export asyncdispatch -type SaveType* = enum - parsedConfig, - upsertManifest, - remoteManifest, - -proc fileDir*(self: SaveType): string = - result = case self - of parsedConfig, upsertManifest: cacheDir - else: tempDir - -proc toDisk*[T]( - self: SaveType, - fname: string, - data: T, - ): Future[string] {.async.} = - ## persists data to cache or temp dir and returns path - ## if file already exists, will overwrite if content is different - raise tddError - # file exists ? - # content is same? return true - # persist data - # lock - # save as self.fileDir / hash(fname) - # unlock - # return success - result = true - -proc fromDisk*[T]( - self: SaveType, - fname: string, - to: T, - errorNotFound = false - ): Future[T] {.async.} = - ## parse to T and return T - ## throws if errorNotFound is true; else returns empty T - raise tddError - # yield readAsync self.fileDir / hash(fname) - # if file not found / cant be read then throw if errorNotFound is true - if errorNotFound and "cant load file" is string: raise fileLoadError - else: result = new(to) +# type SaveType* = enum +# parsedConfig, +# upsertManifest, +# remoteManifest, + +# proc fileDir*(self: SaveType): string = +# result = case self +# of parsedConfig, upsertManifest: cacheDir +# else: tempDir + +# proc toDisk*[T]( +# self: SaveType, +# fname: string, +# data: T, +# ): Future[string] {.async.} = +# ## persists data to cache or temp dir and returns path +# ## if file already exists, will overwrite if content is different +# raise tddError +# # file exists ? +# # content is same? return true +# # persist data +# # lock +# # save as self.fileDir / hash(fname) +# # unlock +# # return success +# result = true + +# proc fromDisk*[T]( +# self: SaveType, +# fname: string, +# to: T, +# errorNotFound = false +# ): Future[T] {.async.} = +# ## parse to T and return T +# ## throws if errorNotFound is true; else returns empty T +# raise tddError +# # yield readAsync self.fileDir / hash(fname) +# # if file not found / cant be read then throw if errorNotFound is true +# if errorNotFound and "cant load file" is string: raise fileLoadError +# else: result = new(to)