From dbe6b403da47172346b2536b50a379e6d9b76e31 Mon Sep 17 00:00:00 2001 From: Joey Hess Date: Fri, 31 Jul 2015 16:00:13 -0400 Subject: Improve shutdown due to --time-limit, especially for fsck * Perform a clean shutdown when --time-limit is reached. This includes running queued git commands, and cleanup actions normally run when a command is finished. * fsck: Commit incremental fsck database when --time-limit is reached. Previously, some of the last files fscked did not make it into the database when using --time-limit. Note that this changes Annex.addCleanup hooks, to run after --time-limit expires. Fsck was using such a hook to clean up after a --incremental-schedule, and that shouldn't run when --time-limit exipires it. So, instead, moved that cleanup code to be run by cleanupIncremental. Resulted in some data type juggling. --- Annex/Action.hs | 35 +++++++++++++++++++++++++++++++++++ 1 file changed, 35 insertions(+) create mode 100644 Annex/Action.hs (limited to 'Annex') diff --git a/Annex/Action.hs b/Annex/Action.hs new file mode 100644 index 000000000..f59c9c2f4 --- /dev/null +++ b/Annex/Action.hs @@ -0,0 +1,35 @@ +{- git-annex actions + - + - Copyright 2010-2015 Joey Hess + - + - Licensed under the GNU GPL version 3 or higher. + -} + +{-# LANGUAGE CPP #-} + +module Annex.Action where + +import qualified Data.Map as M +#ifndef mingw32_HOST_OS +import System.Posix.Signals +#endif + +import Common.Annex +import qualified Annex +import Annex.Content + +{- Actions to perform each time ran. -} +startup :: Annex () +startup = +#ifndef mingw32_HOST_OS + liftIO $ void $ installHandler sigINT Default Nothing +#else + return () +#endif + +{- Cleanup actions. -} +shutdown :: Bool -> Annex () +shutdown nocommit = do + saveState nocommit + sequence_ =<< M.elems <$> Annex.getState Annex.cleanup + liftIO reapZombies -- zombies from long-running git processes -- cgit v1.2.3