fix for Windows file timestamp timezone madness
On Windows, changing the time zone causes the apparent mtime of files to change. This confuses git-annex, which natually thinks this means the files have actually been modified (since THAT'S WHAT A MTIME IS FOR, BILL <sheesh>). Work around this stupidity, by using the inode sentinal file to detect if the timezone has changed, and calculate a TSDelta, which will be applied when generating InodeCaches. This should add no overhead at all on unix. Indeed, I sped up a few things slightly in the refactoring. Seems to basically work! But it has a big known problem: If the timezone changes while the assistant (or a long-running command) runs, it won't notice, since it only checks the inode cache once, and so will use the old delta for all new inode caches it generates for new files it's added. Which will result in them seeming changed the next time it runs. This commit was sponsored by Vincent Demeester.
This commit is contained in:
parent
db8982c45b
commit
e4d7e2ebde
6 changed files with 153 additions and 60 deletions
|
@ -102,7 +102,7 @@ lockDown = either (\e -> showErr e >> return Nothing) (return . Just) <=< lockDo
|
|||
|
||||
lockDown' :: FilePath -> Annex (Either IOException KeySource)
|
||||
lockDown' file = ifM crippledFileSystem
|
||||
( liftIO $ tryIO nohardlink
|
||||
( withTSDelta $ liftIO . tryIO . nohardlink
|
||||
, tryAnnexIO $ do
|
||||
tmp <- fromRepo gitAnnexTmpMiscDir
|
||||
createAnnexDirectory tmp
|
||||
|
@ -122,22 +122,22 @@ lockDown' file = ifM crippledFileSystem
|
|||
go tmp = do
|
||||
unlessM isDirect $
|
||||
freezeContent file
|
||||
liftIO $ do
|
||||
withTSDelta $ \delta -> liftIO $ do
|
||||
(tmpfile, h) <- openTempFile tmp $
|
||||
relatedTemplate $ takeFileName file
|
||||
hClose h
|
||||
nukeFile tmpfile
|
||||
withhardlink tmpfile `catchIO` const nohardlink
|
||||
nohardlink = do
|
||||
cache <- genInodeCache file
|
||||
withhardlink delta tmpfile `catchIO` const (nohardlink delta)
|
||||
nohardlink delta = do
|
||||
cache <- genInodeCache file delta
|
||||
return KeySource
|
||||
{ keyFilename = file
|
||||
, contentLocation = file
|
||||
, inodeCache = cache
|
||||
}
|
||||
withhardlink tmpfile = do
|
||||
withhardlink delta tmpfile = do
|
||||
createLink file tmpfile
|
||||
cache <- genInodeCache tmpfile
|
||||
cache <- genInodeCache tmpfile delta
|
||||
return KeySource
|
||||
{ keyFilename = file
|
||||
, contentLocation = tmpfile
|
||||
|
@ -151,11 +151,11 @@ lockDown' file = ifM crippledFileSystem
|
|||
-}
|
||||
ingest :: Maybe KeySource -> Annex (Maybe Key, Maybe InodeCache)
|
||||
ingest Nothing = return (Nothing, Nothing)
|
||||
ingest (Just source) = do
|
||||
ingest (Just source) = withTSDelta $ \delta -> do
|
||||
backend <- chooseBackend $ keyFilename source
|
||||
k <- genKey source backend
|
||||
ms <- liftIO $ catchMaybeIO $ getFileStatus $ contentLocation source
|
||||
let mcache = toInodeCache =<< ms
|
||||
let mcache = toInodeCache delta =<< ms
|
||||
case (mcache, inodeCache source) of
|
||||
(_, Nothing) -> go k mcache ms
|
||||
(Just newc, Just c) | compareStrong c newc -> go k mcache ms
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue