horrible impementation of isInodeKnown

The only good thing about it is it does not require a major version bump
to improve the database. That will need to happen at some point though.

Potentially very very slow in a large repository.

Ugly use of raw sql.
This commit is contained in:
Joey Hess 2019-10-23 14:06:11 -04:00
parent eebf080b33
commit 94efc400e9
No known key found for this signature in database
GPG key ID: DB12DB0FF05F8F38
4 changed files with 65 additions and 2 deletions

View file

@ -23,6 +23,7 @@ module Utility.InodeCache (
showInodeCache,
genInodeCache,
toInodeCache,
likeInodeCacheWeak,
InodeCacheKey,
inodeCacheToKey,
@ -149,6 +150,22 @@ showInodeCache (InodeCache (InodeCachePrim inode size (MTimeLowRes mtime))) =
, show mtime
]
-- Generates patterns that can be used in a SQL LIKE query to match
-- serialized inode caches that are weakly the same as the provided
-- InodeCache.
--
-- Like compareWeak, the size has to match, while the mtime can differ
-- by anything less than 2 seconds.
likeInodeCacheWeak :: InodeCache -> [String]
likeInodeCacheWeak (InodeCache (InodeCachePrim _ size mtime)) =
lowresl ++ highresl
where
lowresl = map mkpat [t, t+1, t-1]
highresl = map (++ " %") lowresl
t = lowResTime mtime
mkpat t' = "% " ++ ssz ++ " " ++ show t'
ssz = show size
readInodeCache :: String -> Maybe InodeCache
readInodeCache s = case words s of
(inode:size:mtime:[]) -> do