Skip to content

Commit ba0e0df

Browse files
alimirjamalippisar
authored andcommitted
Disallow dnf download non-sense without --skip-unavailable
resolves: #1151
1 parent 8763cf9 commit ba0e0df

File tree

2 files changed

+12
-0
lines changed

2 files changed

+12
-0
lines changed

dnf5/commands/download/download.cpp

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -158,6 +158,7 @@ void DownloadCommand::set_argument_parser() {
158158
cmd.register_named_arg(resolve);
159159
cmd.register_named_arg(alldeps);
160160
create_destdir_option(*this);
161+
auto skip_unavailable = std::make_unique<SkipUnavailableOption>(*this);
161162
cmd.register_named_arg(srpm);
162163
cmd.register_named_arg(url);
163164
cmd.register_named_arg(urlprotocol);
@@ -212,6 +213,14 @@ void DownloadCommand::run() {
212213
pkg_query.filter_arch(std::vector<std::string>(arch_option.begin(), arch_option.end()));
213214
}
214215

216+
if (!pkg_query.size() && !ctx.get_base().get_config().get_skip_unavailable_option().get_value()) {
217+
// User tried `dnf5 download non-sense` or `dnf download non-sense-wildcard*`
218+
throw libdnf5::cli::CommandExitError(
219+
1,
220+
M_("No package \"{}\" available; You might want to use --skip-unavailable option."),
221+
option->get_value());
222+
}
223+
215224
for (const auto & pkg : pkg_query) {
216225
download_pkgs.insert(create_nevra_pkg_pair(pkg));
217226

doc/commands/download.8.rst

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -50,6 +50,9 @@ Options
5050
``--destdir=<path>``
5151
| Set directory used for downloading packages to. Default location is to the current working directory.
5252
53+
``--skip-unavailable``
54+
| Allow skipping packages that are not available in repositories. All available packages will be downloaded.
55+
5356
``--srpm``
5457
| Download the source rpm. Enables source repositories of all enabled binary repositories.
5558

0 commit comments

Comments
 (0)