# Buggy code
def execute(self):
    # I hate inline imports, but I guess it's ok since we're importing from the conda.core
    # The alternative is passing the the classes to ExtractPackageAction __init__
    from .package_cache import PackageCache, PackageCacheEntry

    log.trace("extracting %s => %s", self.source_full_path, self.target_full_path)

    if lexists(self.hold_path):
        rm_rf(self.hold_path)
    if lexists(self.target_full_path):
        backoff_rename(self.target_full_path, self.hold_path)
    extract_tarball(self.source_full_path, self.target_full_path)

    target_package_cache = PackageCache(self.target_pkgs_dir)

    recorded_url = target_package_cache.urls_data.get_url(self.source_full_path)
    dist = (
        Dist(recorded_url) if recorded_url else Dist(path_to_url(self.source_full_path))
    )
    package_cache_entry = PackageCacheEntry.make_legacy(self.target_pkgs_dir, dist)
    target_package_cache[package_cache_entry.dist] = package_cache_entry


# Traceback (conda.CondaMultiError)
Traceback (most recent call last):
File "/root/miniconda3/lib/python3.5/site-packages/conda/exceptions.py", line 617, in conda_exception_handler
return_value = func(*args, **kwargs)
File "/root/miniconda3/lib/python3.5/site-packages/conda_env/cli/main_create.py", line 112, in execute
installer.install(prefix, pkg_specs, args, env)
File "/root/miniconda3/lib/python3.5/site-packages/conda_env/installers/conda.py", line 37, in install
plan.execute_actions(actions, index, verbose=not args.quiet)
File "/root/miniconda3/lib/python3.5/site-packages/conda/plan.py", line 837, in execute_actions
execute_instructions(plan, index, verbose)
File "/root/miniconda3/lib/python3.5/site-packages/conda/instructions.py", line 258, in execute_instructions
cmd(state, arg)
File "/root/miniconda3/lib/python3.5/site-packages/conda/instructions.py", line 111, in PROGRESSIVEFETCHEXTRACT_CMD
progressive_fetch_extract.execute()
File "/root/miniconda3/lib/python3.5/site-packages/conda/core/package_cache.py", line 467, in execute
self._execute_action(action)
File "/root/miniconda3/lib/python3.5/site-packages/conda/core/package_cache.py", line 489, in _execute_action
raise CondaMultiError(exceptions)
conda.CondaMultiError: OSError(18, 'Invalid cross-device link')
OSError(18, 'Invalid cross-device link')
OSError(18, 'Invalid cross-device link')

# Fixed code
def execute(self):
    # I hate inline imports, but I guess it's ok since we're importing from the conda.core
    # The alternative is passing the the classes to ExtractPackageAction __init__
    from .package_cache import PackageCache, PackageCacheEntry

    log.trace("extracting %s => %s", self.source_full_path, self.target_full_path)

    if lexists(self.hold_path):
        rm_rf(self.hold_path)
    if lexists(self.target_full_path):
        try:
            backoff_rename(self.target_full_path, self.hold_path)
        except (IOError, OSError) as e:
            if e.errno == EXDEV:
                # OSError(18, 'Invalid cross-device link')
                # https://github.com/docker/docker/issues/25409
                # ignore, but we won't be able to roll back
                log.debug(
                    "Invalid cross-device link on rename %s => %s",
                    self.target_full_path,
                    self.hold_path,
                )
                rm_rf(self.target_full_path)
            else:
                raise
    extract_tarball(self.source_full_path, self.target_full_path)

    target_package_cache = PackageCache(self.target_pkgs_dir)

    recorded_url = target_package_cache.urls_data.get_url(self.source_full_path)
    dist = (
        Dist(recorded_url) if recorded_url else Dist(path_to_url(self.source_full_path))
    )
    package_cache_entry = PackageCacheEntry.make_legacy(self.target_pkgs_dir, dist)
    target_package_cache[package_cache_entry.dist] = package_cache_entry