prevent relatedTemplate from truncating a filename to end in whitespace

Avoid a problem with temp file names ending in whitespace on filesystems
like VFAT that don't support such filenames.

See a6eb7d7339 previously for the same but
with "."

At some point relatedTemplate is more bother than it's worth and it would
be simpler to just use "temp" as the basename of all temp files. We seem to
be approaching that point, since my interest in absurd ancient filesystem
limitations is limited.

Sponsored-by: unqueued on Patreon
This commit is contained in:
Joey Hess 2025-06-23 13:31:15 -04:00
parent 6818e69b81
commit 2007507e2b
No known key found for this signature in database
GPG key ID: DB12DB0FF05F8F38
3 changed files with 9 additions and 3 deletions

View file

@ -2,6 +2,8 @@ git-annex (10.20250606) UNRELEASED; urgency=medium
* Skip and warn when a tree import includes empty filenames, * Skip and warn when a tree import includes empty filenames,
which can happen with eg a S3 bucket. which can happen with eg a S3 bucket.
* Avoid a problem with temp file names ending in whitespace on
filesystems like VFAT that don't support such filenames.
-- Joey Hess <id@joeyh.name> Mon, 23 Jun 2025 11:11:29 -0400 -- Joey Hess <id@joeyh.name> Mon, 23 Jun 2025 11:11:29 -0400

View file

@ -117,13 +117,15 @@ relatedTemplate' :: RawFilePath -> RawFilePath
relatedTemplate' f relatedTemplate' f
| len > templateAddedLength = | len > templateAddedLength =
{- Some filesystems like FAT have issues with filenames {- Some filesystems like FAT have issues with filenames
- ending in ".", so avoid truncating a filename to end - ending in ".", and others like VFAT don't allow a
- that way. -} - filename to end with trailing whitespace, so avoid
B.dropWhileEnd (== dot) $ - truncating a filename to end that way. -}
B.dropWhileEnd disallowed $
truncateFilePath (len - templateAddedLength) f truncateFilePath (len - templateAddedLength) f
| otherwise = f | otherwise = f
where where
len = B.length f len = B.length f
disallowed c = c == dot || isSpace (chr (fromIntegral c))
dot = fromIntegral (ord '.') dot = fromIntegral (ord '.')
#else #else
-- Avoids a test suite failure on windows, reason unknown, but -- Avoids a test suite failure on windows, reason unknown, but

View file

@ -43,3 +43,5 @@ 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) ### 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)
I use it quite successfully to archive media on removable spinning hard drives. I use it quite successfully to archive media on removable spinning hard drives.
> [[fixed|done]] --[[Joey]]