diff options
author | Joey Hess <joey@kitenet.net> | 2011-03-16 11:27:29 -0400 |
---|---|---|
committer | Joey Hess <joey@kitenet.net> | 2011-03-16 11:27:29 -0400 |
commit | 744638197f51811fca13a37c7bbc51dfb626793b (patch) | |
tree | 4bbf67dc64a0abfe8477ed8f3bba881564f0ba2a /Content.hs | |
parent | a0807999001017bd6897bad82e747c16e18af6bc (diff) |
fix getKeyspresent to work with hashed dirs
Diffstat (limited to 'Content.hs')
-rw-r--r-- | Content.hs | 16 |
1 files changed, 12 insertions, 4 deletions
diff --git a/Content.hs b/Content.hs index 1a5a80a9f..a59484b5a 100644 --- a/Content.hs +++ b/Content.hs @@ -161,13 +161,21 @@ getKeysPresent' dir = do if (not exists) then return [] else do - contents <- liftIO $ getDirectoryContents dir - files <- liftIO $ filterM present contents - return $ catMaybes $ map fileKey files + -- 2 levels of hashing + levela <- liftIO $ subdirContent dir + levelb <- liftIO $ mapM subdirContent levela + contents <- liftIO $ mapM subdirContent (concat levelb) + files <- liftIO $ filterM present (concat contents) + return $ catMaybes $ map (fileKey . takeFileName) files where present d = do result <- try $ - getFileStatus $ dir ++ "/" ++ d ++ "/" ++ takeFileName d + getFileStatus $ d </> takeFileName d + liftIO $ putStrLn $ "trying " ++ (d </> takeFileName d) case result of Right s -> return $ isRegularFile s Left _ -> return False + subdirContent d = do + c <- getDirectoryContents d + return $ map (d </>) $ filter notcruft c + notcruft f = f /= "." && f /= ".." |