Repository: Cog-Creators/Red-DiscordBot

Issue:
[Downloader] Actually use disabled key in updates
~~Regression from 3.1.8 -> dev, disabled key doesnt prevent install~~ False Alarm on regression.

Same from 3.1.8 -> dev, disabled key doesnt prevent loading an updated cog which was made disabled.

CC: @jack1142 , discord API issues may make it easier to discuss issue here.


Discussion:
Due to current discord's issues I haven't actually been able to test any of this, but after taking a second look at the code, it looks like the issue with `[p]cog install*` is probably me overlooking something - those commands are most likely preventing install of a disabled cog in both 3.1.8 and dev.

But the issue with `[p]cog update` is still valid, at least to some degree.
I'm gonna go ahead and assign you on this one, but there's no rush on this. It will be nice to have this working for 3.2 and we have a lot to still handle for 3.2 with the only real timeframe for release being "when it's ready"

If the scope of the issue is wrong, it can be corrected after verification, I just went with what you presented to get us started here.
I was more worried about the possible regression here, but from the code it looks like `[p]cog install*` commands most likely work fine (waiting to be able to test it 😄).
From what I've been able to figure out from code, `[p]cog update*` *shouldn't* get any errors because of the cog being disabled so there should be no regression here either.

The only issue (but at least not regression) *should* be cogs showing as possible to update when the version they can be updated to is disabled. Therefore `[p]cog checkforupdates` will show incorrect output and `[p]cog update*` commands will update that cog to disabled version.

But of course, all this can be corrected in issue description after I'll verify it.
After testing, looks like `[p]cog install*` commands are fine (no regression, no issues related to disabled cogs).

Only `[p]cog checkforupdates` and `[p]cog update*` commands are not handling disabled cogs correctly - cogs can be updated despite the updated version having a disabled key set to true. Something I didn't expect though - this is a a regression from 3.1.8 as it turns out that it's not possible to update to disabled version of a cog on 3.1.8.

@mikeshardmind can you update issue description accordingly? Thanks.

Resolving patch:
diff --git a/redbot/cogs/downloader/downloader.py b/redbot/cogs/downloader/downloader.py
--- a/redbot/cogs/downloader/downloader.py
+++ b/redbot/cogs/downloader/downloader.py
@@ -252,7 +252,7 @@ async def _available_updates(
                 continue
             # marking cog for update if there's no commit data saved (back-compat, see GH-2571)
             last_cog_occurrence = await cog.repo.get_last_module_occurrence(cog.name)
-            if last_cog_occurrence is not None:
+            if last_cog_occurrence is not None and not last_cog_occurrence.disabled:
                 cogs_to_update.add(last_cog_occurrence)
 
         # Reduces diff requests to a single dict with no repeats
@@ -277,7 +277,8 @@ async def _available_updates(
                 else:
                     modified_module = modified[index]
                     if modified_module.type == InstallableType.COG:
-                        cogs_to_update.add(modified_module)
+                        if not modified_module.disabled:
+                            cogs_to_update.add(modified_module)
                     elif modified_module.type == InstallableType.SHARED_LIBRARY:
                         libraries_to_update.add(modified_module)
 


Test patch: