Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Background
CKAN stores downloads in a cache, so if you install a module twice, it won't be downloaded twice. Currently this cache lives at the game-instance level. Let's say for the sake of argument that a user had several game instances:
Then each of these would have its own independent download cache, at
<GameRoot>/CKAN/downloads
.Problems
Three Caches for the Elven-kings under the sky,
Seven for the Dwarf-lords in halls of stone,
Nine for Mortal Men, doomed to die,
... is a bit much for CKAN.
Previous approaches
#2185 started addressing this, but it had some problems and @Olympic1 has been too busy to develop it further. This pull request tries to learn from and avoid the issues that came up in that effort.
ckan help
didn't show thecache
commandregistry.json
files were loaded at startup, causing a big performance hit0000400
isn't an octal literal in C#GUIConfig.xml
file), which is kind of awkward to coordinate and opens the door to things getting out of syncChanges
Core
The cache object is removed from the game-instance level altogether; the
KSP
class no longer has aCache
property (though it retains its cache folder property). Instead the cache now lives inKSPManager
, the object that sits above all the instances. This makes it a truly global cache.Various places have been updated to pass a cache or manager object where an instance would have worked previously.
Cache size measurement and clearing are migrated into the cache object itself.
The cache writes new downloads into one configurable location.The default cache location is:
~/.local/share/CKAN/downloads
C:\Users\<user>\AppData\Local\CKAN\downloads
This can be overridden by using the various UIs to set a Windows/Mono registry key:
This allows the user to select a location on their system with the appropriate combination of capacity and responsiveness, according to their preferences. When you change the setting, files are migrated from the old folder to the new.
If the user has old cache folders in his existing game instances, these will be checked after the main cache folder but not written to. This ensures that previously downloaded files will not be re-downloaded regardless of the instances in which they were originally downloaded or newly needed. The user is free to migrate or purge these folders or leave them alone as he pleases. By not auto-migrating the contents of such folders, we avoid the risk of filling a disk when moving lots of big files from one folder to another.
Newly configured game instances will not have a
CKAN/downloads
folder created.Netkan
Netkan is updated to use the configurable global cache. The
--cachedir
parameter still overrides the default path, so the bot should not be affected.CmdLine
CmdLine now has several new subcommands (which show up in
ckan help
):ckan cache list
- show the current cache location and sizeckan cache set <path>
- change the cache locationckan cache clear
- delete all the files in the cacheckan cache reset
- set the cache location back to the defaultGUI
The GUI settings window's cache section is re-done:
If you type an invalid folder, the text description between the field and the buttons turns red and explains the problem (and the most recent valid selection will be used if the window is closed):
There is no "nag" feature on startup. Rather, the new cache structure will "just work" without the user having to worry about the details, but if they want to change it, it's there in the settings.
Fixes #584.
Fixes #960.
Closes #2185.