mirror of
https://github.com/spalencsar/bearhub.git
synced 2026-07-09 17:54:14 +02:00
[fix][arch] clean cache
This commit is contained in:
@@ -63,7 +63,7 @@ class SystemProcess:
|
|||||||
|
|
||||||
class SimpleProcess:
|
class SimpleProcess:
|
||||||
|
|
||||||
def __init__(self, cmd: List[str], cwd: str = '.', expected_code: int = None,
|
def __init__(self, cmd: List[str], cwd: str = '.', expected_code: int = 0,
|
||||||
global_interpreter: bool = USE_GLOBAL_INTERPRETER, lang: str = DEFAULT_LANG, root_password: str = None,
|
global_interpreter: bool = USE_GLOBAL_INTERPRETER, lang: str = DEFAULT_LANG, root_password: str = None,
|
||||||
extra_paths: Set[str] = None, error_phrases: Set[str] = None):
|
extra_paths: Set[str] = None, error_phrases: Set[str] = None):
|
||||||
pwdin, final_cmd = None, []
|
pwdin, final_cmd = None, []
|
||||||
@@ -179,7 +179,7 @@ class ProcessHandler:
|
|||||||
proc.instance.wait()
|
proc.instance.wait()
|
||||||
output.seek(0)
|
output.seek(0)
|
||||||
|
|
||||||
success = proc.instance.returncode == proc.expected_code,
|
success = proc.instance.returncode == proc.expected_code
|
||||||
string_output = output.read()
|
string_output = output.read()
|
||||||
|
|
||||||
if proc.error_phrases:
|
if proc.error_phrases:
|
||||||
|
|||||||
@@ -2163,10 +2163,17 @@ class ArchManager(SoftwareManager):
|
|||||||
body=text,
|
body=text,
|
||||||
confirmation_label=self.i18n['clean'].capitalize(),
|
confirmation_label=self.i18n['clean'].capitalize(),
|
||||||
deny_label=self.i18n['cancel'].capitalize()):
|
deny_label=self.i18n['cancel'].capitalize()):
|
||||||
rm = SimpleProcess(cmd=['rm', '-rf', '{}/*'.format(cache_dir)], root_password=root_password)
|
|
||||||
|
|
||||||
handler = ProcessHandler(watcher)
|
handler = ProcessHandler(watcher)
|
||||||
success, output = handler.handle_simple(rm)
|
success = True
|
||||||
|
for f in glob.glob('{}/*'.format(cache_dir)):
|
||||||
|
rm = SimpleProcess(cmd=['rm', '-rf', f], root_password=root_password)
|
||||||
|
|
||||||
|
success, _ = handler.handle_simple(rm)
|
||||||
|
|
||||||
|
if not success:
|
||||||
|
success = False
|
||||||
|
break
|
||||||
|
|
||||||
if success:
|
if success:
|
||||||
watcher.show_message(title=self.i18n['arch.custom_action.clean_cache'].capitalize(),
|
watcher.show_message(title=self.i18n['arch.custom_action.clean_cache'].capitalize(),
|
||||||
|
|||||||
@@ -838,7 +838,13 @@ def get_cache_dir() -> str:
|
|||||||
if not string.strip().startswith('#'):
|
if not string.strip().startswith('#'):
|
||||||
cache_dirs.append(string.split('=')[1].strip())
|
cache_dirs.append(string.split('=')[1].strip())
|
||||||
|
|
||||||
return cache_dirs[-1] if cache_dirs else '/var/cache/pacman/pkg/'
|
if cache_dirs:
|
||||||
|
if cache_dirs[-1][-1] == '/':
|
||||||
|
return cache_dirs[-1][0:-1]
|
||||||
|
else:
|
||||||
|
return cache_dirs[-1]
|
||||||
|
else:
|
||||||
|
return '/var/cache/pacman/pkg'
|
||||||
|
|
||||||
|
|
||||||
def map_required_by(names: Iterable[str]) -> Dict[str, Set[str]]:
|
def map_required_by(names: Iterable[str]) -> Dict[str, Set[str]]:
|
||||||
|
|||||||
Reference in New Issue
Block a user