diff --git a/src/cal_tools/constants.py b/src/cal_tools/constants.py index a5052a1e261c23b83aae5f2c86ffd5fb36caf759..82cbcc85b1a90fd82f27661334a443ff357fba89 100644 --- a/src/cal_tools/constants.py +++ b/src/cal_tools/constants.py @@ -184,15 +184,17 @@ def inject_ccv(const_src, ccv_root, report_to): } } - resp = CalibrationClient.inject_new_calibration_constant_version(calibration_client(), inject_h) - - if not resp['success']: - raise RuntimeError(resp) - const_dest = _get_default_caldb_root() / const_rel_path / const_filename const_dest.parent.mkdir(parents=True, exist_ok=True) copyfile(const_src, const_dest) + resp = CalibrationClient.inject_new_calibration_constant_version( + calibration_client(), inject_h) + + if not resp['success']: + const_dest.unlink() # Delete already copied CCV file. + raise RuntimeError(resp) + def inject_ccv_legacy(in_folder, metadata_folder, runs, calibration, cond, pdu, const_input, begin_at):