* Skip and warn when a tree import includes empty filenames,
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
relatedTemplate' f
| len > templateAddedLength =
{- Some filesystems like FAT have issues with filenames
- - ending in ".", so avoid truncating a filename to end
- - that way. -}
- B.dropWhileEnd (== dot) $
+ - ending in ".", and others like VFAT don't allow a
+ - filename to end with trailing whitespace, so avoid
+ - truncating a filename to end that way. -}
+ B.dropWhileEnd disallowed $
truncateFilePath (len - templateAddedLength) f
| otherwise = f
where
len = B.length f
+ disallowed c = c == dot || isSpace (chr (fromIntegral c))
dot = fromIntegral (ord '.')
#else
-- Avoids a test suite failure on windows, reason unknown, but