summaryrefslogtreecommitdiff
path: root/Types/ScheduledActivity.hs
diff options
context:
space:
mode:
Diffstat (limited to 'Types/ScheduledActivity.hs')
-rw-r--r--Types/ScheduledActivity.hs31
1 files changed, 31 insertions, 0 deletions
diff --git a/Types/ScheduledActivity.hs b/Types/ScheduledActivity.hs
new file mode 100644
index 000000000..e2b8d088a
--- /dev/null
+++ b/Types/ScheduledActivity.hs
@@ -0,0 +1,31 @@
+{- git-annex scheduled activities
+ -
+ - Copyright 2013 Joey Hess <joey@kitenet.net>
+ -
+ - Licensed under the GNU GPL version 3 or higher.
+ -}
+
+module Types.ScheduledActivity where
+
+import Common
+import Utility.Scheduled
+import Types.UUID
+
+data ScheduledActivity
+ = ScheduledSelfFsck Schedule
+ | ScheduledRemoteFsck UUID Schedule
+
+fromScheduledActivity :: ScheduledActivity -> String
+fromScheduledActivity (ScheduledSelfFsck s) =
+ "fsck self at " ++ fromSchedule s
+fromScheduledActivity (ScheduledRemoteFsck u s) =
+ "fsck " ++ fromUUID u ++ " at " ++ fromSchedule s
+
+toScheduledActivity :: String -> Maybe ScheduledActivity
+toScheduledActivity s = case words s of
+ ("fsck":"self":rest) -> ScheduledSelfFsck
+ <$> toSchedule (unwords rest)
+ ("fsck":u:rest) -> ScheduledRemoteFsck
+ <$> pure (toUUID u)
+ <*> toSchedule (unwords rest)
+ _ -> Nothing