add getExportedKey

Not optimised because that would need transition code to be written for
existing export datbases.
This commit is contained in:
Joey Hess 2019-03-04 17:25:29 -04:00
parent 138d07eb97
commit b67fa2180e
No known key found for this signature in database
GPG key ID: DB12DB0FF05F8F38

View file

@ -19,6 +19,7 @@ module Database.Export (
addExportedLocation,
removeExportedLocation,
getExportedLocation,
getExportedKey,
isExportDirectoryEmpty,
getExportTreeCurrent,
recordExportTreeCurrent,
@ -154,6 +155,20 @@ getExportedLocation (ExportHandle h _) k = H.queryDbQueue h $ do
where
ik = toIKey k
{- Get the key that was exported to a location.
-
- Note that the database does not currently have an index to make this
- fast.
-
- Note that this does not see recently queued changes.
-}
getExportedKey :: ExportHandle -> ExportLocation -> IO [Key]
getExportedKey ExportHandle h _) el = H.queryDbQueue h $ do
l <- selectList [ExportedFile ==. ef] []
return $ map (fromSKey . exportedKey . entityVal) l
where
ef = toSFilePath (fromExportLocation el)
{- Note that this does not see recently queued changes. -}
isExportDirectoryEmpty :: ExportHandle -> ExportDirectory -> IO Bool
isExportDirectoryEmpty (ExportHandle h _) d = H.queryDbQueue h $ do