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:
parent
eebf080b33
commit
94efc400e9
4 changed files with 65 additions and 2 deletions
|
@ -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
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue