git-annex/Build
Joey Hess 10b5f79e2d
fix empty tree import when directory does not exist
Fix behavior when importing a tree from a directory remote when the
directory does not exist. An empty tree was imported, rather than the
import failing. Merging that tree would delete every file in the
branch, if those files had been exported to the directory before.

The problem was that dirContentsRecursive returned [] when the directory
did not exist. Better for it to throw an exception. But in commit
74f0d67aa3 back in 2012, I made it never
theow exceptions, because exceptions throw inside unsafeInterleaveIO become
untrappable when the list is being traversed.

So, changed it to list the contents of the directory before entering
unsafeInterleaveIO. So exceptions are thrown for the directory. But still
not if it's unable to list the contents of a subdirectory. That's less of a
problem, because the subdirectory does exist (or if not, it got removed
after being listed, and it's ok to not include it in the list). A
subdirectory that has permissions that don't allow listing it will have its
contents omitted from the list still.

(Might be better to have it return a type that includes indications of
errors listing contents of subdirectories?)

The rest of the changes are making callers of dirContentsRecursive
use emptyWhenDoesNotExist when they relied on the behavior of it not
throwing an exception when the directory does not exist. Note that
it's possible some callers of dirContentsRecursive that used to ignore
permissions problems listing a directory will now start throwing exceptions
on them.

The fix to the directory special remote consisted of not making its
call in listImportableContentsM use emptyWhenDoesNotExist. So it will
throw an exception as desired.

Sponsored-by: Joshua Antonishen on Patreon
2023-08-15 12:57:41 -04:00
..
BuildVersion.hs type signature 2018-08-04 14:21:30 -04:00
BundledPrograms.hs include libmagic in windows installer 2020-10-26 13:24:37 -04:00
collect-ghc-options.sh Makefile: Pass LDFLAGS, CFLAGS, and CPPFLAGS through ghc and on to ld, cc, and cpp. 2015-08-19 13:53:57 -04:00
Configure.hs Windows: Support long filenames in more (possibly all) of the code 2023-03-01 15:55:58 -04:00
DesktopFile.hs support building with unix-compat 0.7 2023-08-01 15:17:43 -04:00
DistributionUpdate.hs fix empty tree import when directory does not exist 2023-08-15 12:57:41 -04:00
InstallDesktopFile.hs update licenses from GPL to AGPL 2019-03-13 15:48:14 -04:00
LinuxMkLibs.hs Apply codespell -w throughout 2023-03-17 15:14:58 -04:00
MakeMans.hs update licenses from GPL to AGPL 2019-03-13 15:48:14 -04:00
Mans.hs deal with cabal unpack not preserving execute bit 2021-02-08 14:32:24 -04:00
mdwn2man fix formatting of \ continued shell examples in man pages 2023-07-13 19:55:38 -04:00
NullSoftInstaller.hs Windows: Correct the path to the html help file for 64 bit build. 2021-02-24 13:19:42 -04:00
OSXMkLibs.hs Apply codespell -w throughout 2023-03-17 15:14:58 -04:00
Standalone.hs update after RawFilePath transition 2020-11-09 12:12:25 -04:00
TestConfig.hs Windows: Support long filenames in more (possibly all) of the code 2023-03-01 15:55:58 -04:00
Version.hs avoid strictness problem 2019-01-22 19:37:49 -04:00