1
0
mirror of https://github.com/ciromattia/kcc synced 2026-07-04 12:05:34 +00:00

fix: enable unrar on all distros, not just Fedora (#1376)

* fix: enable unrar on all distros, not just Fedora

unrar was gated behind distro.id() == 'fedora', so on Debian/Ubuntu
the binary was installed but never invoked. Try unrar unconditionally
after 7z, with an optional rarfile Python fallback.

Fixes CBR extraction on non-Fedora Linux distributions.

* fix: gate unrar on Linux and drop unused distro dependency

Debian/Ubuntu's '7zip' package ships the upstream 7zz binary, which
excludes RAR support for licensing reasons, so 7z fails to read .cbr
(RAR) archives. unrar was installed but only invoked when
distro.id() == 'fedora', so on Debian it was never tried and extraction
failed.

Per maintainer feedback, gate unrar on platform.system() == 'Linux'
(not needed on Windows or macOS) and drop the rarfile PyPI fallback to
avoid a new dependency. Since the code no longer imports distro, also
remove it from the requirements files and setup.py.
This commit is contained in:
Nils Leo
2026-07-03 00:07:36 +02:00
committed by GitHub
parent 544e866b51
commit 72e1546c2c
6 changed files with 6 additions and 12 deletions
+6 -7
View File
@@ -22,7 +22,6 @@ from functools import cached_property, lru_cache
import os
from pathlib import Path
import platform
import distro
from subprocess import STDOUT, PIPE, CalledProcessError
from xml.dom.minidom import parseString
from xml.parsers.expat import ExpatError
@@ -41,12 +40,12 @@ class ComicArchive:
self.dirname, self.basename = os.path.split(filepath)
@cached_property
def type(self):
def type(self):
extraction_commands = [
[SEVENZIP, 'l', '-y', '-p1', self.basename],
]
if distro.id() == 'fedora' or distro.like() == 'fedora':
if platform.system() == 'Linux':
extraction_commands.append(
['unrar', 'l', '-y', '-p1', self.basename],
)
@@ -85,20 +84,20 @@ class ComicArchive:
extraction_commands.reverse()
if distro.id() == 'fedora' or distro.like() == 'fedora':
if platform.system() == 'Linux':
extraction_commands.append(
['unrar', 'x', '-y', '-x__MACOSX', '-x.DS_Store', '-xthumbs.db', '-xThumbs.db', self.basename, targetdir]
)
for cmd in extraction_commands:
try:
subprocess_run(cmd, capture_output=True, check=True, cwd=self.dirname)
return targetdir
return targetdir
except FileNotFoundError:
missing.append(cmd[0])
except CalledProcessError:
pass
if missing:
raise OSError(f'Extraction failed, install <a href="https://github.com/ciromattia/kcc#7-zip">specialized extraction software.</a> ')
else: