commit: c9ed8136f9f0c56dc7b72d400eaa0acbd338778f Author: Konstantin Tokarev <annulen <AT> yandex <DOT> ru> AuthorDate: Fri Jan 12 17:47:45 2024 +0000 Commit: Sam James <sam <AT> gentoo <DOT> org> CommitDate: Tue Jan 16 05:16:08 2024 +0000 URL: https://gitweb.gentoo.org/proj/portage.git/commit/?id=c9ed8136
vartree: _needs_move() should replace file if filecmp fails for whatever reason When trying to update I've got "OSError: [Errno 5] Input/output error" exception traceback from portage originating from _needs_move(). It turned out that 3 files in my root filesystem were corrupted, which caused filecmp to fail. This patch makes portage replace original file in this case. Bug: https://bugs.gentoo.org/722270 Signed-off-by: Konstantin Tokarev <annulen <AT> yandex.ru> Closes: https://github.com/gentoo/portage/pull/1233 Signed-off-by: Sam James <sam <AT> gentoo.org> lib/portage/dbapi/vartree.py | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) diff --git a/lib/portage/dbapi/vartree.py b/lib/portage/dbapi/vartree.py index 5d39ca1965..a00c731c57 100644 --- a/lib/portage/dbapi/vartree.py +++ b/lib/portage/dbapi/vartree.py @@ -6283,7 +6283,19 @@ class dblink: if not _cmpxattr(src_bytes, dest_bytes, exclude=excluded_xattrs): return True - return not filecmp.cmp(src_bytes, dest_bytes, shallow=False) + try: + files_equal = filecmp.cmp(src_bytes, dest_bytes, shallow=False) + except Exception as e: + writemsg( + _( + "Exception '%s' happened when comparing files %s and %s, will replace the latter\n" + ) + % (e, mysrc, mydest), + noiselevel=-1, + ) + return True + + return not files_equal def merge(
