git-annex/Remote
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
..
Directory improve createDirectoryUnder to allow alternate top directories 2022-08-12 12:52:37 -04:00
External split out Utility.Url.Parse 2023-08-14 12:28:10 -04:00
Helper fix empty tree import when directory does not exist 2023-08-15 12:57:41 -04:00
List
Rsync add newtypes for QuickCheck to avoid LANG=C issues 2020-11-09 20:21:18 -04:00
WebDAV Apply codespell -w throughout 2023-03-17 15:14:58 -04:00
Adb.hs filter out control characters in warning messages 2023-04-10 15:55:44 -04:00
BitTorrent.hs split out Utility.Url.Parse 2023-08-14 12:28:10 -04:00
Borg.hs Apply codespell -w throughout 2023-03-17 15:14:58 -04:00
Bup.hs Apply codespell -w throughout 2023-03-17 15:14:58 -04:00
Ddar.hs filter out control characters in error messages 2023-04-10 13:50:51 -04:00
Directory.hs fix build with unix-2.8.0 2023-08-01 18:41:27 -04:00
External.hs filter out control characters in all other Messages 2023-04-11 12:58:01 -04:00
GCrypt.hs gcrypt: Remove empty hash directories when dropping content 2023-07-21 16:04:11 -04:00
Git.hs Honor --force option when operating on a local git remote 2023-04-19 12:53:58 -04:00
GitLFS.hs filter out control characters in warning messages 2023-04-10 15:55:44 -04:00
Glacier.hs added an optional cost= configuration to all special remotes 2023-01-12 13:42:28 -04:00
Hook.hs filter out control characters in warning messages 2023-04-10 15:55:44 -04:00
HttpAlso.hs fix build warnings 2023-06-21 13:06:11 -04:00
List.hs start borg special remote 2020-12-18 16:03:51 -04:00
P2P.hs filter out control characters in warning messages 2023-04-10 15:55:44 -04:00
Rsync.hs filter out control characters in all other Messages 2023-04-11 12:58:01 -04:00
S3.hs enable TypeOperators 2023-08-01 18:33:39 -04:00
Tahoe.hs added an optional cost= configuration to all special remotes 2023-01-12 13:42:28 -04:00
Web.hs Typo: sansative -> sensitive 2023-03-17 15:14:50 -04:00
WebDAV.hs filter out control characters in error messages 2023-04-10 13:50:51 -04:00