Created
December 2, 2019 18:15
-
-
Save dmwit/20b885f189e037df6c3e5eeba91774e8 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
find fp = do | |
entry <- entityFromFile fp | |
mold <- lookupEntity (entityHash entry) | |
pure $ case mold of | |
Nothing -> ImportAdded entry | |
Just old | entityPath old == entityPath entry -> ImportUpToDate entry | |
_ -> ImportMoved old entry | |
act (ImportAdded entry) = do | |
dbPutEntity entry | |
forM_ (entityPath entry) $ flip dbPutPath entry | |
act (ImportUpToDate entry) = pure () | |
act (ImportMoved old entry) = do | |
dbPutEntity old { entityPath = entityPath entry } | |
forM_ (entityPath old) $ dbDel . asPathKey | |
forM_ (entityPath entry) $ \path -> do | |
unlinkPath path | |
dbPutPath path entry |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment