diff --git a/backport-Allow-local-downloads-to-same-downloaddir.patch b/backport-Allow-local-downloads-to-same-downloaddir.patch
new file mode 100644
index 0000000000000000000000000000000000000000..acf9f4428c95c5d2386d7de2fa57506dcc00ffa4
--- /dev/null
+++ b/backport-Allow-local-downloads-to-same-downloaddir.patch
@@ -0,0 +1,30 @@
+From dee3952a8c19d733b7c5b1d854b1ccde947d770d Mon Sep 17 00:00:00 2001
+From: Nic <138107617+nicbadiu@users.noreply.github.com>
+Date: Fri, 28 Jun 2024 12:56:34 +0300
+Subject: [PATCH] Allow local downloads to same `downloaddir`
+
+Currently when `dnf download --downloaddir
` sources`` from `` it triggers a `shutil.SameFileError` exception and aborts the entire download process.
+
+This goes against the current flow which marks locally present RPMs that match a remote RPM as `[SKIPPED] .rpm: Already downloaded`.
+
+This change allows downloads of locally sourced packages to the same file, treating it as a no-op.
+---
+ dnf/base.py | 5 ++++-
+ 1 file changed, 4 insertions(+), 1 deletion(-)
+
+diff --git a/dnf/base.py b/dnf/base.py
+index dac3cefd7a..c1affc8cba 100644
+--- a/dnf/base.py
++++ b/dnf/base.py
+@@ -1320,7 +1320,10 @@ def download_packages(self, pkglist, progress=None, callback_total=None):
+ pkg.location.lstrip("/"))
+ else:
+ location = os.path.join(pkg.repo.pkgdir, pkg.location.lstrip("/"))
+- shutil.copy(location, self.conf.destdir)
++ try:
++ shutil.copy(location, self.conf.destdir)
++ except shutil.SameFileError:
++ pass
+
+ def add_remote_rpms(self, path_list, strict=True, progress=None):
+ # :api
diff --git a/dnf.spec b/dnf.spec
index 2a98a04e90bcaeeb98e485a1196c3aba675cc4b0..2e747cc79d574df3453495df581a5461d32f40ea 100644
--- a/dnf.spec
+++ b/dnf.spec
@@ -3,7 +3,7 @@
Name: dnf
Version: 4.14.0
-Release: 22
+Release: 23
Summary: A software package manager that manages packages on Linux distributions.
License: GPL-2.0-or-later AND GPL-1.0-only
URL: https://github.com/rpm-software-management/dnf
@@ -33,6 +33,7 @@ Patch6013: backport-Add-all-candidates-for-reinstall-to-solver.patch
Patch6014: backport-Limit-queries-to-nevra-forms-when-provided-by-command.patch
Patch6015: backport-doc-Remove-provide-of-spec-definition-for-repoquery-command.patch
Patch6016: backport-Update-the-man-page-entry-for-the-countme-option.patch
+Patch6017: backport-Allow-local-downloads-to-same-downloaddir.patch
BuildArch: noarch
BuildRequires: cmake gettext systemd bash-completion python3-sphinx
@@ -257,6 +258,12 @@ popd
%{_mandir}/man8/%{name}-automatic.8*
%changelog
+* Sat Oct 19 2024 hanhuihui - 4.14.0-23
+- Type:bugfix
+- CVE:NA
+- SUG:NA
+- DESC:Allow local downloads to same downloaddir
+
* Sun Sep 08 2024 Funda Wang - 4.14.0-22
- Drop wrong obsolete tag