Repository: conda/conda

Issue:
Option to fall back to old file format
The rollout of the new file format has exposed some problems in conda-package-handling.  Some/all packages are missing symlinks (at least to folders) which makes conda barf about missing content.

We need a way for users to get unstuck if the new format doesn't work for them for whatever reason.


Discussion:

Resolving patch:
diff --git a/conda/base/context.py b/conda/base/context.py
--- a/conda/base/context.py
+++ b/conda/base/context.py
@@ -237,6 +237,7 @@ class Context(Configuration):
     report_errors = PrimitiveParameter(None, element_type=(bool, NoneType))
     shortcuts = PrimitiveParameter(True)
     _verbosity = PrimitiveParameter(0, aliases=('verbose', 'verbosity'), element_type=int)
+    use_only_tar_bz2 = PrimitiveParameter(False)
 
     # ######################################################
     # ##               Solver Configuration               ##
@@ -722,6 +723,7 @@ def category_map(self):
             'allow_non_channel_urls',
             'restore_free_channel',
             'repodata_fn',
+            'use_only_tar_bz2'
         )),
         ('Basic Conda Configuration', (  # TODO: Is there a better category name here?
             'envs_dirs',
@@ -1129,6 +1131,9 @@ def description_map(self):
                 allowed, along with the --use-local command line flag, be sure to include the
                 'local' channel in the list. If the list is empty or left undefined, no
                 channel exclusions will be enforced.
+                """),
+            'use_only_tar_bz2': dals("""
+                A boolean indicating that only .tar.bz2 conda packages should be downloaded
                 """)
         })
 
diff --git a/conda/cli/install.py b/conda/cli/install.py
--- a/conda/cli/install.py
+++ b/conda/cli/install.py
@@ -126,13 +126,14 @@ def get_revision(arg, json=False):
     except ValueError:
         raise CondaValueError("expected revision number, not: '%s'" % arg, json)
 
-
 def install(args, parser, command='install'):
     """
     conda install, conda update, and conda create
     """
     context.validate_configuration()
     check_non_admin()
+    if context.use_only_tar_bz2:
+        args.repodata_fn = 'repodata.json'
 
     newenv = bool(command == 'create')
     isupdate = bool(command == 'update')
diff --git a/conda/core/subdir_data.py b/conda/core/subdir_data.py
--- a/conda/core/subdir_data.py
+++ b/conda/core/subdir_data.py
@@ -382,7 +382,8 @@ def _process_raw_repodata_str(self, raw_repodata_str):
 
         channel_url = self.url_w_credentials
         legacy_packages = json_obj.get("packages", {})
-        conda_packages = json_obj.get("packages.conda", {})
+        conda_packages = {} if context.use_only_tar_bz2 else json_obj.get("packages.conda", {})
+
         _tar_bz2 = CONDA_PACKAGE_EXTENSION_V1
         use_these_legacy_keys = set(iterkeys(legacy_packages)) - set(
             k[:-6] + _tar_bz2 for k in iterkeys(conda_packages)
@@ -407,6 +408,7 @@ def _process_raw_repodata_str(self, raw_repodata_str):
                     log.debug("Ignoring record_version %d from %s",
                               info["record_version"], info['url'])
                     continue
+
                 package_record = PackageRecord(**info)
 
                 _package_records.append(package_record)


Test patch:
diff --git a/tests/core/test_subdir_data.py b/tests/core/test_subdir_data.py
--- a/tests/core/test_subdir_data.py
+++ b/tests/core/test_subdir_data.py
@@ -188,6 +188,15 @@ def test_subdir_data_prefers_conda_to_tar_bz2():
     precs = tuple(sd.query("zlib"))
     assert precs[0].fn.endswith(".conda")
 
+
+def test_only_use_tar_bz2():
+    channel = Channel(join(dirname(__file__), "..", "data", "conda_format_repo", context.subdir))
+    context.use_only_tar_bz2 = True
+    sd = SubdirData(channel)
+    precs = tuple(sd.query("zlib"))
+    assert precs[0].fn.endswith(".tar.bz2")
+
+
 # @pytest.mark.integration
 # class SubdirDataTests(TestCase):
 #