From c7e67aa29183c7fe7bb14b909cf953a89c531b08 Mon Sep 17 00:00:00 2001 From: Joey Hess Date: Tue, 20 Jan 2015 16:58:48 -0400 Subject: add getFileSize, which can get the real size of a large file on Windows Avoid using fileSize which maxes out at just 2 gb on Windows. Instead, use hFileSize, which doesn't have a bounded size. Fixes support for files > 2 gb on Windows. Note that the InodeCache code only needs to compare a file size, so it doesn't matter it the file size wraps. So it has been left as-is. This was necessary both to avoid invalidating existing inode caches, and because the code passed FileStatus around and would have become more expensive if it called getFileSize. This commit was sponsored by Christian Dietrich. --- Command/Fsck.hs | 3 +-- Command/Info.hs | 3 +-- Command/RecvKey.hs | 3 +-- 3 files changed, 3 insertions(+), 6 deletions(-) (limited to 'Command') diff --git a/Command/Fsck.hs b/Command/Fsck.hs index 46c1620f1..5dad10127 100644 --- a/Command/Fsck.hs +++ b/Command/Fsck.hs @@ -303,8 +303,7 @@ checkKeySizeOr :: (Key -> Annex String) -> Key -> FilePath -> Annex Bool checkKeySizeOr bad key file = case Types.Key.keySize key of Nothing -> return True Just size -> do - size' <- fromIntegral . fileSize - <$> liftIO (getFileStatus file) + size' <- liftIO $ getFileSize file comparesizes size size' where comparesizes a b = do diff --git a/Command/Info.hs b/Command/Info.hs index 36d93a270..86b608928 100644 --- a/Command/Info.hs +++ b/Command/Info.hs @@ -490,8 +490,7 @@ staleSize label dirspec = go =<< lift (dirKeys dirspec) keysizes keys = do dir <- lift $ fromRepo dirspec liftIO $ forM keys $ \k -> catchDefaultIO 0 $ - fromIntegral . fileSize - <$> getFileStatus (dir keyFile k) + getFileSize (dir keyFile k) aside :: String -> String aside s = " (" ++ s ++ ")" diff --git a/Command/RecvKey.hs b/Command/RecvKey.hs index 8a806875b..424ca923d 100644 --- a/Command/RecvKey.hs +++ b/Command/RecvKey.hs @@ -62,8 +62,7 @@ start key = fieldTransfer Download key $ \_p -> oksize <- case Types.Key.keySize key of Nothing -> return True Just size -> do - size' <- fromIntegral . fileSize - <$> liftIO (getFileStatus tmp) + size' <- liftIO $ getFileSize tmp return $ size == size' if oksize then case Backend.maybeLookupBackendName (Types.Key.keyBackendName key) of -- cgit v1.2.3