fix: keep why a data tree or a copy failed

A damaged member of a data tree's archive (zlib.error, EOFError) ended
the run on a traceback, and a failed write left its .part. --offline
refusing a data tree, or the download after a --from copy failed, lost
its kind, so the advice named the network instead of --offline.
This commit is contained in:
Abdessamad Derraz committed 2026-10-23 20:49:23 +02:00
1 parent abba99d352
commit a296bbfdff
5 files changed
+103 -32

No files matched your search

+12
View File
@@ -520,6 +520,18 @@ class ACopyThatFails(FromFolder):
self.assertNotIn(install.NOT_WRITABLE, reason)
self.assertIsInstance(reason, install.NetworkReason)
def test_offline_the_fallback_keeps_the_offline_reason(self):
"""The copy failed, the download was refused by --offline: the
joined reason lost its kind, and the advice named neither."""
_unprivileged(self)
self.source.chmod(0)
self.addCleanup(self.source.chmod, 0o644)
with mock.patch.dict(os.environ, {install.OFFLINE_VARIABLE: "1"}):
_dest, ok, reason = install._download_one(self.entry, self.dest, copy=self.copy)
self.assertFalse(ok)
self.assertIsInstance(reason, install.OfflineReason)
self.assertIn("could not be read: Permission denied, and not fetched", reason)
def test_a_read_error_is_the_source_and_not_the_folder(self):
class Failing(io.BytesIO):
def read(self, *_args):