rescue spmsync: fix handlePackage failure when installed DB is missing

Two fixes for `equo rescue spmsync` on a system without an existing
installed packages DB:

1. client/interfaces/methods.py: Stop falling back to a GenericRepository
   (in-memory, read-only for handlePackage) when the DB file is absent.
   Instead let SQLite create the file; call initializeRepository() on a
   freshly created DB so validate() succeeds.  Corrupted DBs still fall
   back to RAM via the existing DatabaseError/SystemDatabaseError path.

2. spm/portage_plugin: Also catch OSError (not just tarfile.ReadError)
   when uncompress_tarball fails on a pure-XPAK temp file; Python 3.14
   raises OSError in this case rather than tarfile.ReadError.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
Mario Fetka
2026-07-02 00:04:31 +02:00
parent 655f2f26d2
commit d7ddf15fac
2 changed files with 26 additions and 28 deletions
+25 -27
View File
@@ -1085,36 +1085,34 @@ class RepositoryMixin:
os.makedirs(db_dir)
db_path = repo_path
if (self._installed_repo_enable) and (not os.path.isfile(db_path)):
conn = load_db_from_ram()
db_file_is_new = not os.path.isfile(db_path)
try:
repo_class = self.get_repository(name)
conn = repo_class(readOnly = False,
dbFile = db_path,
xcache = self.xcache,
indexing = self._indexing)
conn.setCloseToken(name)
self._add_plugin_to_client_repository(conn)
if db_file_is_new:
conn.initializeRepository()
# TODO: remove this in future, drop useless data from clientdb
except (DatabaseError,):
entropy.tools.print_traceback(f = self.logger)
conn = load_db_from_ram()
else:
try:
repo_class = self.get_repository(name)
conn = repo_class(readOnly = False,
dbFile = db_path,
xcache = self.xcache,
indexing = self._indexing)
conn.setCloseToken(name)
self._add_plugin_to_client_repository(conn)
# TODO: remove this in future, drop useless data from clientdb
except (DatabaseError,):
entropy.tools.print_traceback(f = self.logger)
conn = load_db_from_ram()
else:
# validate database
if self._installed_repo_enable:
# validate database
if self._installed_repo_enable:
try:
conn.validate()
except SystemDatabaseError:
try:
conn.validate()
except SystemDatabaseError:
try:
conn.close(_token = name)
except (RepositoryPluginError, OSError, IOError):
pass
entropy.tools.print_traceback(f = self.logger)
conn = load_db_from_ram()
conn.close(_token = name)
except (RepositoryPluginError, OSError, IOError):
pass
entropy.tools.print_traceback(f = self.logger)
conn = load_db_from_ram()
self._real_installed_repository = conn
return conn
@@ -1421,7 +1421,7 @@ class PortagePlugin(SpmPlugin):
try:
entropy.tools.uncompress_tarball(package_file,
extract_path = pkg_dir, catch_empty = False)
except tarfile.ReadError:
except (tarfile.ReadError, OSError):
empty_content = True
env_bz2 = os.path.join(meta_dir, PortagePlugin.ENV_FILE_COMP)