Add exception capture

This commit is contained in:
small_leek 2023-02-22 00:25:35 +08:00
parent a5d4496684
commit 405261dd10
2 changed files with 33 additions and 25 deletions

View File

@ -3,7 +3,7 @@
Name: dnf
Version: 4.14.0
Release: 10
Release: 11
Summary: A software package manager that manages packages on Linux distributions.
License: GPLv2+ and GPLv2 and GPL
URL: https://github.com/rpm-software-management/dnf
@ -252,6 +252,9 @@ popd
%{_mandir}/man8/%{name}-automatic.8*
%changelog
* Wed Feb 22 2023 xiasenlin <xiasenlin1@huawei.com> - 4.14.0-11
- DESC:Add exception capture to get-lockfile-exists-before-unlick.patch
* Fri Feb 17 2023 chenhaixing <chenhaixing@huawei.com> 4.14.0-10
- Type:bugfix
- CVE:NA

View File

@ -1,24 +1,29 @@
From 5cf9fbe5096c807668da3c1685c917996b91c960 Mon Sep 17 00:00:00 2001
From: Duan Pengjie <pengjieduan@gmail.com>
Date: Wed, 4 Jan 2023 11:51:23 +0800
Subject: [PATCH] add exists
---
dnf/lock.py | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/dnf/lock.py b/dnf/lock.py
index ee7a0db..a94132a 100644
--- a/dnf/lock.py
+++ b/dnf/lock.py
@@ -161,6 +161,6 @@ class ProcessLock(object):
pid = self._try_lock(my_pid)
def __exit__(self, *exc_args):
- if self.count == 1:
+ if self.count == 1 and os.path.exists(self.target):
os.unlink(self.target)
self._unlock_thread()
--
2.37.1 (Apple Git-137.1)
From a569c1cd79d225f928e00b5ab3e0084ddaa41334 Mon Sep 17 00:00:00 2001
From: small_leek <xiasenlin1@huawei.com>
Date: Tue, 21 Feb 2023 20:29:39 +0800
Subject: [PATCH] add patch
---
dnf/lock.py | 8 ++++++--
1 file changed, 6 insertions(+), 2 deletions(-)
diff --git a/dnf/lock.py b/dnf/lock.py
index ee7a0db..851030e 100644
--- a/dnf/lock.py
+++ b/dnf/lock.py
@@ -161,6 +161,10 @@ class ProcessLock(object):
pid = self._try_lock(my_pid)
def __exit__(self, *exc_args):
- if self.count == 1:
- os.unlink(self.target)
+ if self.count == 1 and os.path.exists(self.target):
+ try:
+ os.unlink(self.target)
+ except FileNotFoundError as err:
+ msg = _('No %s existed, please check!') % (self.target)
+ logger.warning(msg)
self._unlock_thread()
--
2.33.0