Gentoo Archives: gentoo-commits

From: Zac Medico <zmedico@g.o>
To: gentoo-commits@l.g.o
Subject: [gentoo-commits] proj/portage:master commit in: lib/portage/util/_async/
Date: Sun, 02 May 2021 00:00:09
Message-Id: 1619912947.bfe550f69ac4e0126412bc83f7e6f6f0d1c6dc1f.zmedico@gentoo
1 commit: bfe550f69ac4e0126412bc83f7e6f6f0d1c6dc1f
2 Author: Zac Medico <zmedico <AT> gentoo <DOT> org>
3 AuthorDate: Sat May 1 23:38:50 2021 +0000
4 Commit: Zac Medico <zmedico <AT> gentoo <DOT> org>
5 CommitDate: Sat May 1 23:49:07 2021 +0000
6 URL: https://gitweb.gentoo.org/proj/portage.git/commit/?id=bfe550f6
7
8 PipeLogger: handle FileNotFoundError when cancelled during _start
9
10 Bug: https://bugs.gentoo.org/787542
11 Signed-off-by: Zac Medico <zmedico <AT> gentoo.org>
12
13 lib/portage/util/_async/PipeLogger.py | 35 +++++++++++++++++++++++++----------
14 1 file changed, 25 insertions(+), 10 deletions(-)
15
16 diff --git a/lib/portage/util/_async/PipeLogger.py b/lib/portage/util/_async/PipeLogger.py
17 index b7c03043f..a335ce96f 100644
18 --- a/lib/portage/util/_async/PipeLogger.py
19 +++ b/lib/portage/util/_async/PipeLogger.py
20 @@ -33,16 +33,31 @@ class PipeLogger(AbstractPollTask):
21 self._log_file = log_file_path
22 _set_nonblocking(self._log_file.fileno())
23 elif log_file_path is not None:
24 - self._log_file = open(_unicode_encode(log_file_path,
25 - encoding=_encodings['fs'], errors='strict'), mode='ab')
26 - if log_file_path.endswith('.gz'):
27 - self._log_file_real = self._log_file
28 - self._log_file = gzip.GzipFile(filename='', mode='ab',
29 - fileobj=self._log_file)
30 -
31 - portage.util.apply_secpass_permissions(log_file_path,
32 - uid=portage.portage_uid, gid=portage.portage_gid,
33 - mode=0o660)
34 + try:
35 + self._log_file = open(
36 + _unicode_encode(
37 + log_file_path, encoding=_encodings["fs"], errors="strict"
38 + ),
39 + mode="ab",
40 + )
41 +
42 + if log_file_path.endswith(".gz"):
43 + self._log_file_real = self._log_file
44 + self._log_file = gzip.GzipFile(
45 + filename="", mode="ab", fileobj=self._log_file
46 + )
47 +
48 + portage.util.apply_secpass_permissions(
49 + log_file_path,
50 + uid=portage.portage_uid,
51 + gid=portage.portage_gid,
52 + mode=0o660,
53 + )
54 + except FileNotFoundError:
55 + if self._was_cancelled():
56 + self._async_wait()
57 + return
58 + raise
59
60 if isinstance(self.input_fd, int):
61 self.input_fd = os.fdopen(self.input_fd, 'rb', 0)