diff options
author | davidovski <david@davidovski.xyz> | 2021-11-24 22:22:30 +0000 |
---|---|---|
committer | davidovski <david@davidovski.xyz> | 2021-11-24 22:22:30 +0000 |
commit | 77b06090f69264bcc93911664bea2810cd4571ba (patch) | |
tree | 85f9b27f50de66fbcd9b47c01b8386f80aba769f /src/verbs/sync.py | |
parent | 52f1d6e6a5b0e0faca2d397114e107900b01b97d (diff) |
cleaned a few things up
Diffstat (limited to 'src/verbs/sync.py')
-rw-r--r-- | src/verbs/sync.py | 17 |
1 files changed, 16 insertions, 1 deletions
diff --git a/src/verbs/sync.py b/src/verbs/sync.py index e71109d..85e3623 100644 --- a/src/verbs/sync.py +++ b/src/verbs/sync.py @@ -59,11 +59,19 @@ def save_package(package, info, location): util.mkdir(location) package_file = os.path.join(location, package) + exists = False + if os.path.exists(package_file): + with open(package_file, "r") as file: + text = file.read() + exists = info["checksum"] in text + content = "" with open(package_file, "w") as file: file.write("checksum=" + info["checksum"] + "\n") file.write("sources=" + " ".join([source for source in info["sources"]])) + return exists + ###### !!! ####### # THIS SHOULD BE A USER ACTION @@ -125,6 +133,8 @@ def sync(args, options, config): v = options["v"] + new = 0 + for repo in repos: if v: print(colors.LIGHT_BLACK + f"downloading package lists for {repo}...") @@ -141,12 +151,17 @@ def sync(args, options, config): total = len(packages.items()) for package,versions in packages.items(): info = validate_package(package, versions, repo, verbose=v) - save_package(package, info, os.path.join(config["dir"]["packages"], repo)) + if not save_package(package, info, os.path.join(config["dir"]["packages"], repo)): + new += 1 done += 1 util.loading_bar(done, total, f"Syncing {repo}") util.loading_bar(total, total, f"Synced {repo}") print(colors.RESET) + + if new > 0: + util.fill_line(f"There are {new} new updates", colors.LIGHT_GREEN) + if "key_authority" in config: imported = 0 |