add pamac-cache-clean and save cache options

This commit is contained in:
2017-10-15 17:04:01 -03:00
parent a605886d80
commit 082f63603a
17 changed files with 246 additions and 15 deletions

View File

@@ -30,6 +30,8 @@ namespace Pamac {
public bool search_aur { get; private set; }
public string aur_build_dir { get; private set; }
public bool check_aur_updates { get; private set; }
public uint64 keep_num_pkgs { get; private set; }
public bool rm_only_uninstalled { get; private set; }
public unowned HashTable<string,string> environment_variables {
get {
return _environment_variables;
@@ -75,6 +77,8 @@ namespace Pamac {
search_aur = false;
aur_build_dir = "/tmp";
check_aur_updates = false;
keep_num_pkgs = 3;
rm_only_uninstalled = false;
parse_file (conf_path);
}
@@ -118,6 +122,13 @@ namespace Pamac {
}
} else if (key == "CheckAURUpdates") {
check_aur_updates = true;
} else if (key == "KeepNumPackages") {
if (splitted.length == 2) {
unowned string val = splitted[1]._strip ();
keep_num_pkgs = uint64.parse (val);
}
} else if (key == "OnlyRmUninstalled") {
rm_only_uninstalled = true;
}
}
} catch (GLib.Error e) {
@@ -213,6 +224,24 @@ namespace Pamac {
} else {
data.append (line + "\n");
}
} else if (line.contains ("KeepNumPackages")) {
if (new_conf.lookup_extended ("KeepNumPackages", null, out variant)) {
data.append ("KeepNumPackages = %llu\n".printf (variant.get_uint64 ()));
new_conf.remove ("KeepNumPackages");
} else {
data.append (line + "\n");
}
} else if (line.contains ("OnlyRmUninstalled")) {
if (new_conf.lookup_extended ("OnlyRmUninstalled", null, out variant)) {
if (variant.get_boolean ()) {
data.append ("OnlyRmUninstalled\n");
} else {
data.append ("#OnlyRmUninstalled\n");
}
new_conf.remove ("OnlyRmUninstalled");
} else {
data.append (line + "\n");
}
} else {
data.append (line + "\n");
}
@@ -266,6 +295,14 @@ namespace Pamac {
} else {
data.append ("#CheckAURUpdates\n");
}
} else if (key == "KeepNumPackages") {
data.append ("KeepNumPackages = %llu\n".printf (val.get_uint64 ()));
} else if (key == "OnlyRmUninstalled") {
if (val.get_boolean ()) {
data.append ("OnlyRmUninstalled\n");
} else {
data.append ("#OnlyRmUninstalled\n");
}
}
}
}

View File

@@ -427,12 +427,12 @@ namespace Pamac {
});
}
public void clean_cache (uint keep_nb, bool only_uninstalled, GLib.BusName sender) {
public void clean_cache (uint64 keep_nb, bool only_uninstalled, GLib.BusName sender) {
check_authorization.begin (sender, (obj, res) => {
bool authorized = check_authorization.end (res);
if (authorized) {
string[] commands = {"paccache", "-rq"};
commands += "-k%u".printf (keep_nb);
string[] commands = {"paccache", "--nocolor", "-rq"};
commands += "-k%llu".printf (keep_nb);
if (only_uninstalled) {
commands += "-u";
}