crate: store crate before parsing

This commit is contained in:
jackyzy823 2023-04-27 21:28:08 +08:00
parent 30185b6c8d
commit a4f4b0df93

View file

@ -209,6 +209,12 @@ def process_project(
# set version to the latest stable version if it was not specified
crate_file_path, version = download_crate(project, version)
if store_crate:
copy_target = os.path.join(os.getcwd(), f"{package.name}-{package.version}.crate")
if not (os.path.exists(copy_target) and os.path.samefile(crate_file_path, copy_target)):
shutil.copy2(crate_file_path, copy_target)
# process files from a .crate archive
with files_from_crate(crate_file_path, name, version) as (toml_path, doc_files, license_files):
if not license_files:
@ -228,10 +234,4 @@ def process_project(
# ensure metadata is up-to-date with changes from patches
metadata = Metadata.from_cargo(toml_path)
if store_crate:
copy_target = os.path.join(os.getcwd(), f"{package.name}-{package.version}.crate")
if not (os.path.exists(copy_target) and os.path.samefile(crate_file_path, copy_target)):
shutil.copy2(crate_file_path, copy_target)
return name, diffs, metadata, doc_files, license_files