prevent relatedTemplate from truncating a filename to end in "."
Avoid a problem with temp file names ending in "." on certian filesystems that have problems with such filenames. relatedTemplate is quite an ugly hack really; since it doesn't know the max filename length of the filesystem it can only assume that the filename is max allowed length. When given the input "lh.aparc.DKTatlas.annot", it wants to reserve 20 characters for tempfile so it truncates to "lh.". That ending period is apparently a problem on some filesystem (FAT eats it, but does not throw EINVAL; ntfs does not seem bothered by it, I don't know what FUSE filesystem the bug reporter was really using). Sponsored-by: Brett Eisenberg on Patreon
This commit is contained in:
parent
9aa53212a9
commit
a6eb7d7339
4 changed files with 30 additions and 3 deletions
|
@ -4,6 +4,8 @@ git-annex (10.20231130) UNRELEASED; urgency=medium
|
|||
remote.foo.annex-ignore, as documented.
|
||||
* Support git-annex copy/move --from-anywhere --to remote.
|
||||
* sync: Fix locking problems during merge when annex.pidlock is set.
|
||||
* Avoid a problem with temp file names ending in "." on certian
|
||||
filesystems that have problems with such filenames.
|
||||
|
||||
-- Joey Hess <id@joeyh.name> Thu, 30 Nov 2023 14:48:12 -0400
|
||||
|
||||
|
|
|
@ -35,7 +35,9 @@ type Template = String
|
|||
- to help identify what call was responsible.
|
||||
-}
|
||||
openTmpFileIn :: FilePath -> String -> IO (FilePath, Handle)
|
||||
openTmpFileIn dir template = openTempFile dir template
|
||||
openTmpFileIn dir template = do
|
||||
liftIO $ print ("openTmpFileIn", dir, template)
|
||||
openTempFile dir template
|
||||
`catchIO` decoraterrror
|
||||
where
|
||||
decoraterrror e = throwM $
|
||||
|
@ -105,7 +107,12 @@ withTmpFileIn tmpdir template a = bracket create remove use
|
|||
-}
|
||||
relatedTemplate :: FilePath -> FilePath
|
||||
relatedTemplate f
|
||||
| len > 20 = truncateFilePath (len - 20) f
|
||||
| len > 20 =
|
||||
{- Some filesystems like FAT have issues with filenames
|
||||
- ending in ".", so avoid truncating a filename to end
|
||||
- that way. -}
|
||||
reverse $ dropWhile (== '.') $ reverse $
|
||||
truncateFilePath (len - 20) f
|
||||
| otherwise = f
|
||||
where
|
||||
len = length f
|
||||
|
|
|
@ -91,3 +91,5 @@ add: 1 failed
|
|||
### Have you had any luck using git-annex before? (Sometimes we get tired of reading bug reports all day and a lil' positive end note does wonders)
|
||||
|
||||
Yes! I use git annex and datalad all the time for personal and work projects.
|
||||
|
||||
> [[fixed|done]] --[[Joey]]
|
||||
|
|
|
@ -0,0 +1,16 @@
|
|||
[[!comment format=mdwn
|
||||
username="joey"
|
||||
subject="""comment 1"""
|
||||
date="2023-12-05T16:16:35Z"
|
||||
content="""
|
||||
This is EINVAL from probably open(2) or something like that.
|
||||
|
||||
EINVAL The final component ("basename") of pathname is invalid (e.g.,
|
||||
it contains characters not permitted by the underlying filesys‐
|
||||
tem).
|
||||
|
||||
The problem is likely the ending ".", since FAT and probably other Microsoft filesystems
|
||||
don't allow that, and/or have other strange behavior like silently removing that.
|
||||
|
||||
Changed the code to avoid this.
|
||||
"""]]
|
Loading…
Add table
Add a link
Reference in a new issue