summaryrefslogtreecommitdiff
path: root/Database/Keys
diff options
context:
space:
mode:
authorGravatar Joey Hess <joeyh@joeyh.name>2016-10-17 14:58:33 -0400
committerGravatar Joey Hess <joeyh@joeyh.name>2016-10-17 14:58:33 -0400
commit697bb401dbb2a9497e8e3cbc895052ad87a75c23 (patch)
tree75ce98791b4863dea985fa3c16b19d9cc5dfcab5 /Database/Keys
parent124a153411a440c6996315ca0189556aabbae78b (diff)
refactor
Diffstat (limited to 'Database/Keys')
-rw-r--r--Database/Keys/SQL.hs12
1 files changed, 12 insertions, 0 deletions
diff --git a/Database/Keys/SQL.hs b/Database/Keys/SQL.hs
index 88e6ba2dc..77c1e4429 100644
--- a/Database/Keys/SQL.hs
+++ b/Database/Keys/SQL.hs
@@ -68,6 +68,18 @@ addAssociatedFile ik f = queueDb $ do
where
af = toSFilePath (getTopFilePath f)
+-- Does not remove any old association for a file, but less expensive
+-- than addAssociatedFile. Calling dropAllAssociatedFiles first and then
+-- this is an efficient way to update all associated files.
+addAssociatedFileFast :: IKey -> TopFilePath -> WriteHandle -> IO ()
+addAssociatedFileFast ik f = queueDb $ void $ insertUnique $ Associated ik af
+ where
+ af = toSFilePath (getTopFilePath f)
+
+dropAllAssociatedFiles :: WriteHandle -> IO ()
+dropAllAssociatedFiles = queueDb $
+ delete $ from $ \(_r :: SqlExpr (Entity Associated)) -> return ()
+
{- Note that the files returned were once associated with the key, but
- some of them may not be any longer. -}
getAssociatedFiles :: IKey -> ReadHandle -> IO [TopFilePath]