# Buggy code
def get_recipe_sources(
    self, conan_reference, export_folder, export_sources_folder, remote
):
    t1 = time.time()

    def filter_function(urls):
        file_url = urls.get(EXPORT_SOURCES_TGZ_NAME)
        if file_url:
            urls = {EXPORT_SOURCES_TGZ_NAME: file_url}
        else:
            return None
        return urls

    zipped_files = self._call_remote(
        remote, "get_recipe", conan_reference, export_folder, filter_function
    )
    duration = time.time() - t1
    log_recipe_sources_download(conan_reference, duration, remote, zipped_files)

    if not zipped_files:
        mkdir(export_sources_folder)  # create the folder even if no source files
        return

    unzip_and_get_files(zipped_files, export_sources_folder, EXPORT_SOURCES_TGZ_NAME)
    c_src_path = os.path.join(export_sources_folder, ".c_src")
    if os.path.exists(c_src_path):
        merge_directories(c_src_path, export_sources_folder)
        shutil.rmtree(c_src_path)
    for dirname, _, filenames in os.walk(export_sources_folder):
        for fname in filenames:
            touch(os.path.join(dirname, fname))


# Traceback (PermissionError)
PROJECT: Installed build requirements of: myOrg.SomeComponent/2.14.0-alpha-build.5@user/unstable
Downloading conan_sources.tgz

Traceback (most recent call last):
File "d:\buildFolder\virtualenv\lib\site-packages\conans\client\command.py", line 884, in run
method(args[0][1:])
File "d:\buildFolder\virtualenv\lib\site-packages\conans\client\command.py", line 268, in install
filename=args.file, cwd=args.cwd)
File "d:\buildFolder\virtualenv\lib\site-packages\conans\client\conan_api.py", line 57, in wrapper
return f(*args, **kwargs)
File "d:\buildFolder\virtualenv\lib\site-packages\conans\client\conan_api.py", line 399, in install
no_imports=no_imports)
File "d:\buildFolder\virtualenv\lib\site-packages\conans\client\manager.py", line 347, in install
installer.install(deps_graph, current_path)
File "d:\buildFolder\virtualenv\lib\site-packages\conans\client\installer.py", line 135, in install
self._build(nodes_by_level, skip_private_nodes, deps_graph)
File "d:\buildFolder\virtualenv\lib\site-packages\conans\client\installer.py", line 222, in _build
self._remote_proxy.get_recipe_sources(conan_ref, conan_file.short_paths)
File "d:\buildFolder\virtualenv\lib\site-packages\conans\client\proxy.py", line 123, in get_recipe_sources
current_remote)
File "d:\buildFolder\virtualenv\lib\site-packages\conans\client\remote_manager.py", line 199, in get_recipe_sources
shutil.rmtree(c_src_path)
File "d:\buildFolder\virtualenv\lib\shutil.py", line 478, in rmtree
return _rmtree_unsafe(path, onerror)
File "d:\buildFolder\virtualenv\lib\shutil.py", line 368, in _rmtree_unsafe
_rmtree_unsafe(fullname, onerror)
File "d:\buildFolder\virtualenv\lib\shutil.py", line 368, in _rmtree_unsafe
_rmtree_unsafe(fullname, onerror)
File "d:\buildFolder\virtualenv\lib\shutil.py", line 368, in _rmtree_unsafe
_rmtree_unsafe(fullname, onerror)
File "d:\buildFolder\virtualenv\lib\shutil.py", line 368, in _rmtree_unsafe
_rmtree_unsafe(fullname, onerror)
File "d:\buildFolder\virtualenv\lib\shutil.py", line 373, in _rmtree_unsafe
onerror(os.unlink, fullname, sys.exc_info())
File "d:\buildFolder\virtualenv\lib\shutil.py", line 371, in _rmtree_unsafe
os.unlink(fullname)
PermissionError: [WinError 5] Access is denied: 'd:\\buildFolder\\data/.cn\\vy4r6yxd\\1\\.c_src\\SomeComponent\\doc\\QA\\Old\\Testdrehbuch-SomeProject.xls'

ERROR: [WinError 5] Access is denied: 'd:\\buildFolder\\data/.cn\\vy4r6yxd\\1\\.c_src\\SomeComponent\\doc\\QA\\Old\\Testdrehbuch-SomeProject.xls'

# Fixed code
def get_recipe_sources(
    self, conan_reference, export_folder, export_sources_folder, remote
):
    t1 = time.time()

    def filter_function(urls):
        file_url = urls.get(EXPORT_SOURCES_TGZ_NAME)
        if file_url:
            urls = {EXPORT_SOURCES_TGZ_NAME: file_url}
        else:
            return None
        return urls

    zipped_files = self._call_remote(
        remote, "get_recipe", conan_reference, export_folder, filter_function
    )
    duration = time.time() - t1
    log_recipe_sources_download(conan_reference, duration, remote, zipped_files)

    if not zipped_files:
        mkdir(export_sources_folder)  # create the folder even if no source files
        return

    unzip_and_get_files(zipped_files, export_sources_folder, EXPORT_SOURCES_TGZ_NAME)
    c_src_path = os.path.join(export_sources_folder, ".c_src")
    if os.path.exists(c_src_path):
        merge_directories(c_src_path, export_sources_folder)
        rmdir(c_src_path)
    for dirname, _, filenames in os.walk(export_sources_folder):
        for fname in filenames:
            touch(os.path.join(dirname, fname))