Skip to content
This repository has been archived by the owner on Jun 23, 2024. It is now read-only.

[FR] Add a check for max_num #29

Closed
IzzySoft opened this issue Aug 30, 2023 · 4 comments
Closed

[FR] Add a check for max_num #29

IzzySoft opened this issue Aug 30, 2023 · 4 comments

Comments

@IzzySoft
Copy link

{
  "id": "microg_installer",
  "update_to": "https://raw.githubusercontent.com/nift4/microg_installer_revived/master/update.json",
  "license": "GPL-3.0-only",
  "homepage": "",
  "source": "https://github.com/nift4/microg_installer_revived",
  "support": "https://github.com/nift4/microg_installer_revived/issues",
  "donation": "",
  "changelog": "https://raw.githubusercontent.com/nift4/microg_installer_revived/master/CHANGELOG",
  "added": 1679623730.41043,
  "last_update": 1685780590.0,
  "versions": 3,
  "max_num": 1
}

After having run cli.py sync multiple times now, there are still 3 zips in this module's directory. Maybe older versions only get removed once an update was fetched (I will have to wait for that), but I'd expect sync to take care for that when the value has been changed (especially when versions > max_num). If you consider that "works as designed", what would be the proper way to clean up (apart from manually changing the files with the risk of "messing up")? Sometimes "waiting for a new update" might be in vain, or take half a year or more 😉

@SanmerDev
Copy link
Member

There is currently no way to clean it up (other than manually)

@SanmerDev SanmerDev closed this as not planned Won't fix, can't repro, duplicate, stale Aug 30, 2023
@IzzySoft
Copy link
Author

Thanks, so at least I have not overlooked it then. The relevant code would be in Sync.py,more specifically in def _update_jsons, starting at line 74:

        max_num = self._config.max_num
        if track.max_num is not None:
            max_num = track.max_num

        if len(update_json.versions) > max_num:
            old_item = update_json.versions.pop(0)
            for path in module_folder.glob(f"*{old_item.versionCode}*"):
                if not path.is_file():
                    continue

                self._log.d(f"_update_jsons: [{track.id}] -> remove {path.name}")
                path.unlink()

        track.last_update = timestamp
        track.versions = len(update_json.versions)

        update_json.write(update_json_file)
        track.write(track_json_file)

I see you already marked it "not planned" unfortunately; but this could probably be addressed by moving this part to its own def which then could be called from some "cleanup function". I'd consider this a nice-to-have – nothing "high prio" though. In case you reconsider 😉 Thanks again!

@SanmerDev
Copy link
Member

I will add this to the check subcommand.

@SanmerDev SanmerDev reopened this Aug 31, 2023
@SanmerDev SanmerDev changed the title max_num in track.json being ignored? [FR] Add a check for max_num Aug 31, 2023
@IzzySoft
Copy link
Author

IzzySoft commented Sep 3, 2023

Thanks! Tested, works as expected 🤩

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants