aboutsummaryrefslogtreecommitdiff
path: root/Logs/Activity.hs
diff options
context:
space:
mode:
authorGravatar Joey Hess <joeyh@joeyh.name>2015-04-05 12:50:02 -0400
committerGravatar Joey Hess <joeyh@joeyh.name>2015-04-05 12:50:02 -0400
commit2ccd9c5e7cf3266d2270741e1535d78350afcee9 (patch)
tree3e933e4ccf7f53f7f9972fc6c01d6de83d643d28 /Logs/Activity.hs
parentb855580614852c7558fb2aad387609d15c4b0c6b (diff)
rethought distributed fsck; instead add activity.log and expire command
This is much more space efficient!
Diffstat (limited to 'Logs/Activity.hs')
-rw-r--r--Logs/Activity.hs37
1 files changed, 37 insertions, 0 deletions
diff --git a/Logs/Activity.hs b/Logs/Activity.hs
new file mode 100644
index 000000000..45262a633
--- /dev/null
+++ b/Logs/Activity.hs
@@ -0,0 +1,37 @@
+{- git-annex activity log
+ -
+ - Copyright 2015 Joey Hess <id@joeyh.name>
+ -
+ - Licensed under the GNU GPL version 3 or higher.
+ -}
+
+module Logs.Activity (
+ Log,
+ Activity(..),
+ recordActivity,
+ lastActivities,
+) where
+
+import Data.Time.Clock.POSIX
+
+import Common.Annex
+import qualified Annex.Branch
+import Logs
+import Logs.UUIDBased
+
+data Activity = Fsck
+ deriving (Eq, Read, Show, Enum, Bounded)
+
+recordActivity :: Activity -> UUID -> Annex ()
+recordActivity act uuid = do
+ ts <- liftIO getPOSIXTime
+ Annex.Branch.change activityLog $
+ showLog id . changeLog ts uuid (show act) . parseLog readish
+
+lastActivities :: Maybe Activity -> Annex (Log Activity)
+lastActivities wantact = parseLog onlywanted <$> Annex.Branch.get activityLog
+ where
+ onlywanted s = case readish s of
+ Just a | wanted a -> Just a
+ _ -> Nothing
+ wanted a = maybe True (a ==) wantact