1 Star 0 Fork 58

majianhan/dnf

forked from src-openEuler/dnf 
加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
文件
该仓库未声明开源许可证文件(LICENSE),使用请关注具体项目描述及其代码上游依赖。
克隆/下载
backport-Allow-local-downloads-to-same-downloaddir.patch 1.34 KB
一键复制 编辑 原始数据 按行查看 历史
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 <dir> <package>` sources`<package>` from `<dir>` 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] <package>.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 dac3cefd..c1affc8c 100644
--- a/dnf/base.py
+++ b/dnf/base.py
@@ -1320,7 +1320,10 @@ class Base(object):
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
--
2.27.0
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化
1
https://gitee.com/crawfordxx/dnf.git
git@gitee.com:crawfordxx/dnf.git
crawfordxx
dnf
dnf
master

搜索帮助