summaryrefslogtreecommitdiff
path: root/Database/Keys/SQL.hs
diff options
context:
space:
mode:
Diffstat (limited to 'Database/Keys/SQL.hs')
-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]