diff --git a/data/config/pamac.conf b/data/config/pamac.conf index 918a3f4..914381a 100644 --- a/data/config/pamac.conf +++ b/data/config/pamac.conf @@ -28,6 +28,9 @@ RefreshPeriod = 6 ## When check updates from AUR support is enabled check for vcs updates: #CheckAURVCSUpdates +## Number of days to wait before showing AUR updates (0 to disable): +AURUpdateDelayDays = 0 + ## AUR build directory: BuildDirectory = /var/tmp diff --git a/src/database.vala b/src/database.vala index 899b6e8..5b24dd3 100644 --- a/src/database.vala +++ b/src/database.vala @@ -2234,10 +2234,16 @@ namespace Pamac { return pkgnames_table; } - void get_aur_updates_real (GenericArray aur_infos_list, GenericArray vcs_local_pkgs, ref Updates updates) { + void get_aur_updates_real (GenericArray aur_infos_list, GenericArray vcs_local_pkgs, ref Updates updates, bool apply_aur_delay = true) { unowned GenericArray aur_updates = updates.aur_updates; unowned GenericArray outofdate = updates.outofdate; unowned GenericArray ignored_aur_updates = updates.ignored_aur_updates; + DateTime? now = null; + TimeSpan delay_span = 0; + if (apply_aur_delay && config.aur_update_delay_days > 0) { + now = new DateTime.now_local (); + delay_span = TimeSpan.DAY * (int64) config.aur_update_delay_days; + } HashTable vcs_versions = null; if (config.check_aur_vcs_updates) { vcs_versions = get_vcs_last_version (vcs_local_pkgs); @@ -2272,6 +2278,11 @@ namespace Pamac { // set aur_pkg.version aur_pkg.version = new_version; } + if (now != null && aur_infos.lastmodified != null) { + if (now.difference (aur_infos.lastmodified) < delay_span) { + continue; + } + } if (Alpm.pkg_vercmp (new_version, old_version) == 1) { if (alpm_handle.should_ignore (local_pkg) == 1) { ignored_aur_updates.add (aur_pkg); @@ -2320,7 +2331,7 @@ namespace Pamac { } pkgcache.next (); } - get_aur_updates_real (aur_plugin.get_multi_infos (local_pkgs), vcs_local_pkgs, ref updates); + get_aur_updates_real (aur_plugin.get_multi_infos (local_pkgs), vcs_local_pkgs, ref updates, false); // remove ignorepkgs foreach (unowned string name in ignorepkgs) { alpm_handle.remove_ignorepkg (name); diff --git a/src/pamac_config.vala b/src/pamac_config.vala index 373fb54..b892575 100644 --- a/src/pamac_config.vala +++ b/src/pamac_config.vala @@ -139,6 +139,7 @@ namespace Pamac { } } public bool check_aur_vcs_updates { get; set; } + public uint64 aur_update_delay_days { get; set; } public bool download_updates { get { return _download_updates; @@ -247,6 +248,7 @@ namespace Pamac { max_parallel_downloads = 1; clean_keep_num_pkgs = 3; clean_rm_only_uninstalled = false; + aur_update_delay_days = 0; parse_file (conf_path); // limited max_parallel_downloads if (max_parallel_downloads > 10) { @@ -345,6 +347,11 @@ namespace Pamac { check_aur_updates = true; } else if (key == "CheckAURVCSUpdates") { check_aur_vcs_updates = true; + } else if (key == "AURUpdateDelayDays") { + if (splitted.length == 2) { + unowned string val = splitted[1]._strip (); + aur_update_delay_days = uint64.parse (val); + } } else if (key == "DownloadUpdates") { download_updates = true; } else if (key == "OfflineUpgrade") { @@ -389,6 +396,7 @@ namespace Pamac { new_pamac_conf.insert ("KeepBuiltPkgs", new Variant.boolean (keep_built_pkgs)); new_pamac_conf.insert ("CheckAURUpdates", new Variant.boolean (check_aur_updates)); new_pamac_conf.insert ("CheckAURVCSUpdates", new Variant.boolean (check_aur_vcs_updates)); + new_pamac_conf.insert ("AURUpdateDelayDays", new Variant.uint64 (aur_update_delay_days)); new_pamac_conf.insert ("BuildDirectory", new Variant.string (aur_build_dir)); new_pamac_conf.insert ("EnableSnap", new Variant.boolean (enable_snap)); new_pamac_conf.insert ("EnableFlatpak", new Variant.boolean (enable_flatpak)); diff --git a/src/pamac_config_daemon.vala b/src/pamac_config_daemon.vala index e51a8f4..da998d6 100644 --- a/src/pamac_config_daemon.vala +++ b/src/pamac_config_daemon.vala @@ -37,6 +37,7 @@ namespace Pamac { public string aur_build_dir { get; set; } public bool check_aur_updates { get; set; } public bool check_aur_vcs_updates { get; set; } + public uint64 aur_update_delay_days { get; set; } public bool offline_upgrade { get; set; } public uint64 max_parallel_downloads { get; set; } public uint64 clean_keep_num_pkgs { get; set; } @@ -87,6 +88,7 @@ namespace Pamac { aur_build_dir = "/var/tmp"; max_parallel_downloads = 1; offline_upgrade = false; + aur_update_delay_days = 0; parse_file (conf_path); // limited max_parallel_downloads if (max_parallel_downloads > 10) { @@ -167,6 +169,11 @@ namespace Pamac { unowned string val = splitted[1]._strip (); max_parallel_downloads = uint64.parse (val); } + } else if (key == "AURUpdateDelayDays") { + if (splitted.length == 2) { + unowned string val = splitted[1]._strip (); + aur_update_delay_days = uint64.parse (val); + } } } } catch (GLib.Error e) { @@ -361,6 +368,14 @@ namespace Pamac { data.append (line); data.append ("\n"); } + } else if (line.contains ("AURUpdateDelayDays")) { + if (new_conf.lookup_extended ("AURUpdateDelayDays", null, out variant)) { + data.append ("AURUpdateDelayDays = %llu\n".printf (variant.get_uint64 ())); + new_conf.remove ("AURUpdateDelayDays"); + } else { + data.append (line); + data.append ("\n"); + } } else if (line.contains ("DownloadUpdates")) { if (new_conf.lookup_extended ("DownloadUpdates", null, out variant)) { if (variant.get_boolean ()) { @@ -491,6 +506,8 @@ namespace Pamac { } else { data.append ("#CheckAURVCSUpdates\n\n"); } + } else if (key == "AURUpdateDelayDays") { + data.append ("AURUpdateDelayDays = %llu\n\n".printf (val.get_uint64 ())); } else if (key == "DownloadUpdates") { if (val.get_boolean ()) { data.append ("DownloadUpdates\n\n");