From 14709885e84e1cbdc731918a0f38da8fea82cf41 Mon Sep 17 00:00:00 2001 From: Paul Fenwick Date: Thu, 30 Jul 2015 19:03:52 -0700 Subject: [PATCH 1/4] Download default metadata in .tar.gz rather than .zip format At some point, we gained the ability to read `.tar.gz` files, but the client continued to use `.zip` to download metadata. This change flips us to use tarballs, which are *an order of magnitude smaller* than the .zip files. This can make a big difference, especially on slow connections. This change will affect both new users, and existing users if and only if they're using the default repository settings. --- Core/Registry/Registry.cs | 12 ++++++++++++ Core/Types/Repository.cs | 2 +- 2 files changed, 13 insertions(+), 1 deletion(-) diff --git a/Core/Registry/Registry.cs b/Core/Registry/Registry.cs index 1a47254444..a08cc146be 100644 --- a/Core/Registry/Registry.cs +++ b/Core/Registry/Registry.cs @@ -163,6 +163,18 @@ private void DeSerialisationFixes(StreamingContext context) } } + // If we spot a default repo with the old .zip URL, flip it to the new .tar.gz URL + // Any other repo we leave *as-is*, even if it's the github meta-repo, as it's been + // custom-added by our user. + + Repository default_repo; + var OldDefaultRepo = new Uri("https://github.com/KSP-CKAN/CKAN-meta/archive/master.zip"); + if (repositories.TryGetValue(Repository.default_ckan_repo_name, out default_repo) && default_repo.uri == OldDefaultRepo) + { + log.InfoFormat("Updating default metadata URL from {0} to {1}", OldDefaultRepo, Repository.default_ckan_repo_uri); + repositories["default"].uri = Repository.default_ckan_repo_uri; + } + registry_version = LATEST_REGISTRY_VERSION; } diff --git a/Core/Types/Repository.cs b/Core/Types/Repository.cs index 2ecda713c3..2fffedf4dd 100644 --- a/Core/Types/Repository.cs +++ b/Core/Types/Repository.cs @@ -6,7 +6,7 @@ namespace CKAN public class Repository { [JsonIgnore] public static readonly string default_ckan_repo_name = "default"; - [JsonIgnore] public static readonly Uri default_ckan_repo_uri = new Uri("https://github.com/KSP-CKAN/CKAN-meta/archive/master.zip"); + [JsonIgnore] public static readonly Uri default_ckan_repo_uri = new Uri("https://github.com/KSP-CKAN/CKAN-meta/archive/master.tar.gz"); [JsonIgnore] public static readonly Uri default_repo_master_list = new Uri("https://raw.githubusercontent.com/KSP-CKAN/CKAN-meta/master/repositories.json"); public string name; From a1b5d1871ea4d1f127c3297355a4e17289e4472a Mon Sep 17 00:00:00 2001 From: Paul Fenwick Date: Thu, 30 Jul 2015 19:12:11 -0700 Subject: [PATCH 2/4] CHANGELOG: Metadata downloads have MOAR BOOSTERS --- CHANGELOG.md | 1 + 1 file changed, 1 insertion(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index d2f8ea6abd..edbaea63f7 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -21,6 +21,7 @@ All notable changes to this project will be documented in this file. - [GUI] On first start we always refresh the modlist, with an option to do so each time the CKAN is loaded (Postremus, #1285) - [Core] KSP instance names now default to the folder in which they're installed (Postremus, #1261) - [Core] Processing an updated mod list is now faster, and other speed enhancements (Postremus, #1229) +- [Core] Metadata is now downloaded in `.tar.gz` rather than `.zip` format, resulting in much faster downloads (pjf, #1344) - [Spec] `install_to` can now target `Ships/` subdirectories (dbent and plague006, #1243 #1244) ### Internal From ae5bb3e66be87841733344dd6ea258d11881ace7 Mon Sep 17 00:00:00 2001 From: Paul Fenwick Date: Thu, 30 Jul 2015 20:23:20 -0700 Subject: [PATCH 3/4] Fixup: local vars have moreCamels For #1344 --- Core/Registry/Registry.cs | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/Core/Registry/Registry.cs b/Core/Registry/Registry.cs index a08cc146be..56760a9434 100644 --- a/Core/Registry/Registry.cs +++ b/Core/Registry/Registry.cs @@ -168,10 +168,10 @@ private void DeSerialisationFixes(StreamingContext context) // custom-added by our user. Repository default_repo; - var OldDefaultRepo = new Uri("https://github.com/KSP-CKAN/CKAN-meta/archive/master.zip"); - if (repositories.TryGetValue(Repository.default_ckan_repo_name, out default_repo) && default_repo.uri == OldDefaultRepo) + var oldDefaultRepo = new Uri("https://github.com/KSP-CKAN/CKAN-meta/archive/master.zip"); + if (repositories.TryGetValue(Repository.default_ckan_repo_name, out default_repo) && default_repo.uri == oldDefaultRepo) { - log.InfoFormat("Updating default metadata URL from {0} to {1}", OldDefaultRepo, Repository.default_ckan_repo_uri); + log.InfoFormat("Updating default metadata URL from {0} to {1}", oldDefaultRepo, Repository.default_ckan_repo_uri); repositories["default"].uri = Repository.default_ckan_repo_uri; } From fa57da0f24d4ead98e3f2e4c638445a09293c5c5 Mon Sep 17 00:00:00 2001 From: Paul Fenwick Date: Thu, 30 Jul 2015 20:30:25 -0700 Subject: [PATCH 4/4] Registry.cs: Don't try to adjust repositories when *no* repos exist Part of #1344 --- Core/Registry/Registry.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Core/Registry/Registry.cs b/Core/Registry/Registry.cs index 56760a9434..847b692f73 100644 --- a/Core/Registry/Registry.cs +++ b/Core/Registry/Registry.cs @@ -169,7 +169,7 @@ private void DeSerialisationFixes(StreamingContext context) Repository default_repo; var oldDefaultRepo = new Uri("https://github.com/KSP-CKAN/CKAN-meta/archive/master.zip"); - if (repositories.TryGetValue(Repository.default_ckan_repo_name, out default_repo) && default_repo.uri == oldDefaultRepo) + if (repositories != null && repositories.TryGetValue(Repository.default_ckan_repo_name, out default_repo) && default_repo.uri == oldDefaultRepo) { log.InfoFormat("Updating default metadata URL from {0} to {1}", oldDefaultRepo, Repository.default_ckan_repo_uri); repositories["default"].uri = Repository.default_ckan_repo_uri;