Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[ feature ] Automating Mid-Install Temporary Directory Cleanup #301

Open
wants to merge 5 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 3 additions & 2 deletions pack-admin.ipkg
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,10 @@ authors = "Stefan Höck"

brief = "Administration of pack's package collections"

langversion >= 0.6.0
langversion >= 0.7.0

depends = base >= 0.6.0
depends = base >= 0.7.0
, async
, elab-util
, filepath
, getopts
Expand Down
5 changes: 3 additions & 2 deletions pack.ipkg
Original file line number Diff line number Diff line change
Expand Up @@ -6,14 +6,15 @@ authors = "Stefan Höck"

brief = "A package manager for Idris2 with curated package collections"

langversion >= 0.6.0
langversion >= 0.7.0

-- script to run before building
prebuild = "bash version.sh"

postbuild = "bash restore.sh"

depends = base >= 0.6.0
depends = base >= 0.7.0
, async
, elab-util
, filepath
, getopts
Expand Down
2 changes: 1 addition & 1 deletion src/Pack/Admin/Runner.idr
Original file line number Diff line number Diff line change
Expand Up @@ -126,7 +126,7 @@ writeLatestDB : HasIO io => File Abs -> Env -> EitherT PackErr io ()
writeLatestDB path e = write path (printDB e.db)

export covering
runCmd : HasIO io => EitherT PackErr io ()
runCmd : EitherT PackErr IO ()
runCmd = do
pd <- getPackDir
withTmpDir $ do
Expand Down
17 changes: 11 additions & 6 deletions src/Pack/Core/IO.idr
Original file line number Diff line number Diff line change
@@ -1,6 +1,9 @@
module Pack.Core.IO

import public Control.Monad.Either
import IO.Async.Signal
import IO.Async.Type
import IO.Async.Util
import Pack.Config.Types
import Pack.Core.Logging
import Pack.Core.Types
Expand Down Expand Up @@ -326,15 +329,17 @@ mkTmpDir = go 100 0
mkDir dir
pure (TD dir)

export
export covering
withTmpDir :
{auto _ : HasIO io}
-> {auto _ : PackDir}
-> (TmpDir => EitherT PackErr io a)
-> EitherT PackErr io a
{auto _ : PackDir}
-> (TmpDir => EitherT PackErr IO ())
-> EitherT PackErr IO ()
withTmpDir f = do
td <- mkTmpDir
finally (rmDir tmpDir) f
liftIO $ syncApp $ ignore $ race
[ onSignal SigINT (liftIO $ run $ rmDir tmpDir)
, liftIO $ run $ finally (rmDir tmpDir) f
]

--------------------------------------------------------------------------------
-- File Access
Expand Down
4 changes: 2 additions & 2 deletions src/Pack/Runner.idr
Original file line number Diff line number Diff line change
Expand Up @@ -139,9 +139,9 @@ isFetch _ = False

||| Main application entry point (modulo error handling).
export covering
runCmd : HasIO io => EitherT PackErr io ()
runCmd : EitherT PackErr IO ()
runCmd = do
pd <- getPackDir
pd <- getPackDir
withTmpDir $ do
cd <- CD <$> curDir
cache <- emptyCache
Expand Down
Loading