Thanks, Grond for the patch.
* Avoid crashing when there are remotes using unparseable urls.
Including the non-standard URI form that git-remote-gcrypt uses for rsync.
+ * Directory special remotes with importtree=yes now avoid unncessary
+ overhead when inodes of files have changed, as happens whenever a FAT
+ filesystem gets remounted.
-- Joey Hess <id@joeyh.name> Mon, 04 Jan 2021 12:52:41 -0400
{- A "remote" that is just a filesystem directory.
-
- - Copyright 2011-2020 Joey Hess <id@joeyh.name>
+ - Copyright 2011-2021 Joey Hess <id@joeyh.name>
-
- Licensed under the GNU AGPL version 3 or higher.
-}
sz <- getFileSize' f st
return $ Just (mkImportLocation relf, (cid, sz))
--- Make a ContentIdentifier that contains an InodeCache.
+-- Make a ContentIdentifier that contains the size and mtime of the file.
+-- If the file is not a regular file, this will return Nothing.
--
--- The InodeCache is generated without checking a sentinal file.
--- So in a case when a remount etc causes all the inodes to change,
--- files may appear to be modified when they are not, which will only
--- result in extra work to re-import them.
+-- The inode is zeroed because often this is used for import from a
+-- FAT filesystem, whose inodes change each time it's mounted, and
+-- including inodes would cause repeated re-hashing of files, and
+-- bloat the git-annex branch with changes to content identifier logs.
--
--- If the file is not a regular file, this will return Nothing.
+-- This does mean that swaps of two files with the same size and
+-- mtime won't be noticed, nor will modifications to files that
+-- preserve the size and mtime. Both very unlikely so acceptable.
mkContentIdentifier :: RawFilePath -> FileStatus -> IO (Maybe ContentIdentifier)
mkContentIdentifier f st =
fmap (ContentIdentifier . encodeBS . showInodeCache)
- <$> toInodeCache noTSDelta f st
+ <$> toInodeCache' noTSDelta f st 0
guardSameContentIdentifiers :: a -> ContentIdentifier -> Maybe ContentIdentifier -> a
guardSameContentIdentifiers cont old new
showInodeCache,
genInodeCache,
toInodeCache,
+ toInodeCache',
InodeCacheKey,
inodeCacheToKey,
toInodeCache delta f =<< R.getFileStatus f
toInodeCache :: TSDelta -> RawFilePath -> FileStatus -> IO (Maybe InodeCache)
-toInodeCache (TSDelta getdelta) f s
+toInodeCache d f s = toInodeCache' d f s (fileID s)
+
+toInodeCache' :: TSDelta -> RawFilePath -> FileStatus -> FileID -> IO (Maybe InodeCache)
+toInodeCache' (TSDelta getdelta) f s inode
| isRegularFile s = do
delta <- getdelta
sz <- getFileSize' f s
#else
let mtime = modificationTimeHiRes s
#endif
- return $ Just $ InodeCache $ InodeCachePrim (fileID s) sz (MTimeHighRes (mtime + highResTime delta))
+ return $ Just $ InodeCache $ InodeCachePrim inode sz (MTimeHighRes (mtime + highResTime delta))
| otherwise = pure Nothing
{- Some filesystem get new random inodes each time they are mounted.
--- /dev/null
+[[!comment format=mdwn
+ username="joey"
+ subject="""comment 5"""
+ date="2021-01-19T16:53:54Z"
+ content="""
+Well, the changes I made for that todo make changes to inodes due to
+remounting in the middle of an import not cause behavior like this. Of
+course I don't know that's what caused this behavior, but it does seem
+likely those changes would turn out to have fixed this, if we understood
+how to reproduce the problem.
+"""]]