diff --git a/rust2rpm/crate.py b/rust2rpm/crate.py index 24472c2..b17428e 100644 --- a/rust2rpm/crate.py +++ b/rust2rpm/crate.py @@ -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