Skip to content

Add x_netkan_check_parent_downloads#361

Open
Clayell wants to merge 5 commits intoKSP-CKAN:masterfrom
Clayell:master
Open

Add x_netkan_check_parent_downloads#361
Clayell wants to merge 5 commits intoKSP-CKAN:masterfrom
Clayell:master

Conversation

@Clayell
Copy link
Copy Markdown

@Clayell Clayell commented Jan 10, 2026

When x_netkan_check_parent_downloads is false, do not check the github parent repos for the download count. Defaults to true. (the current behavior)
Unsure of how to test this to make sure it works.

Comment thread netkan/netkan/metadata.py Outdated
Comment thread netkan/netkan/metadata.py Outdated
@Clayell
Copy link
Copy Markdown
Author

Clayell commented Jan 27, 2026

@HebaruSan Can you run the github checks again? I don't have the ability to run them on my end, and I'd like to make sure this works (and so that I can begin using it if it gets merged)

Comment thread netkan/netkan/download_counter.py Outdated
for ckan in self.ckm_repo.all_latest_modules(): # pylint: disable=too-many-nested-blocks
if ckan.kind == 'dlc':
continue
nk = Netkan(self.nk_repo.nk_path(ckan.identifier), game_id=self.game_id)
Copy link
Copy Markdown
Member

@HebaruSan HebaruSan Feb 18, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This needs to be able to handle mods that don't have netkans, or for which the netkans are renamed to .frozen. (Note that some of the .frozen files are not valid netkans, e.g. https://github.com/KSP-CKAN/NetKAN/blob/master/NetKAN/BananaForScale.frozen.)
I think it would crash at this point.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Confirmed; here's what those errors look like:

Traceback (most recent call last):
  File "/home/netkan/.local/bin/netkan", line 6, in <module>
    sys.exit(netkan())
             ^^^^^^^^
  File "/home/netkan/.local/lib/python3.12/site-packages/click/core.py", line 1485, in __call__
    return self.main(*args, **kwargs)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/netkan/.local/lib/python3.12/site-packages/click/core.py", line 1406, in main
    rv = self.invoke(ctx)
         ^^^^^^^^^^^^^^^^
  File "/home/netkan/.local/lib/python3.12/site-packages/click/core.py", line 1873, in invoke
    return _process_result(sub_ctx.command.invoke(sub_ctx))
                           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/netkan/.local/lib/python3.12/site-packages/click/core.py", line 1269, in invoke
    return ctx.invoke(self.callback, **ctx.params)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/netkan/.local/lib/python3.12/site-packages/click/core.py", line 824, in invoke
    return callback(*args, **kwargs)
           ^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/netkan/.local/lib/python3.12/site-packages/click/decorators.py", line 93, in new_func
    return ctx.invoke(f, obj, *args, **kwargs)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/netkan/.local/lib/python3.12/site-packages/click/core.py", line 824, in invoke
    return callback(*args, **kwargs)
           ^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/netkan/.local/lib/python3.12/site-packages/netkan/cli/utilities.py", line 64, in download_counter
    common.token).update_counts()
                  ^^^^^^^^^^^^^^^
  File "/home/netkan/.local/lib/python3.12/site-packages/netkan/download_counter.py", line 402, in update_counts
    self.get_counts()
  File "/home/netkan/.local/lib/python3.12/site-packages/netkan/download_counter.py", line 310, in get_counts
    nk = Netkan(self.nk_repo.nk_path(ckan.identifier), game_id=self.game_id)
         ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/netkan/.local/lib/python3.12/site-packages/netkan/metadata.py", line 33, in __init__
    self.contents = self.filename.read_text(encoding='UTF-8')
                    ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/lib/python3.12/pathlib.py", line 1029, in read_text
    with self.open(mode='r', encoding=encoding, errors=errors) as f:
         ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/lib/python3.12/pathlib.py", line 1015, in open
    return io.open(self, mode, buffering, encoding, errors, newline)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
FileNotFoundError: [Errno 2] No such file or directory: '/tmp/ksp/NetKAN/NetKAN/sidosUraniaSystem.netkan'

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I pushed a commit that checks if the netkan file exists first, which is also done by auto_freezer.py in a very similar way. Should account for both situations?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants