1 |
Since DeletionIterator needs to stat the distfile and therefore find |
2 |
one working path for it, pass it to DeletionTask instead of recomputing |
3 |
it there. This also fixes wrongly assuming that first layout will |
4 |
always be correct. |
5 |
|
6 |
Bug: https://bugs.gentoo.org/697890 |
7 |
Signed-off-by: Michał Górny <mgorny@g.o> |
8 |
--- |
9 |
lib/portage/_emirrordist/DeletionIterator.py | 2 ++ |
10 |
lib/portage/_emirrordist/DeletionTask.py | 14 +++++--------- |
11 |
2 files changed, 7 insertions(+), 9 deletions(-) |
12 |
|
13 |
diff --git a/lib/portage/_emirrordist/DeletionIterator.py b/lib/portage/_emirrordist/DeletionIterator.py |
14 |
index 5c193911a..3cbff2c3a 100644 |
15 |
--- a/lib/portage/_emirrordist/DeletionIterator.py |
16 |
+++ b/lib/portage/_emirrordist/DeletionIterator.py |
17 |
@@ -72,6 +72,7 @@ class DeletionIterator(object): |
18 |
|
19 |
yield DeletionTask(background=True, |
20 |
distfile=filename, |
21 |
+ distfile_path=path, |
22 |
config=self._config) |
23 |
|
24 |
else: |
25 |
@@ -85,6 +86,7 @@ class DeletionIterator(object): |
26 |
|
27 |
yield DeletionTask(background=True, |
28 |
distfile=filename, |
29 |
+ distfile_path=path, |
30 |
config=self._config) |
31 |
|
32 |
if deletion_db is not None: |
33 |
diff --git a/lib/portage/_emirrordist/DeletionTask.py b/lib/portage/_emirrordist/DeletionTask.py |
34 |
index a4bb29419..4e9c26ca2 100644 |
35 |
--- a/lib/portage/_emirrordist/DeletionTask.py |
36 |
+++ b/lib/portage/_emirrordist/DeletionTask.py |
37 |
@@ -10,14 +10,9 @@ from _emerge.CompositeTask import CompositeTask |
38 |
|
39 |
class DeletionTask(CompositeTask): |
40 |
|
41 |
- __slots__ = ('distfile', 'config') |
42 |
+ __slots__ = ('distfile', 'distfile_path', 'config') |
43 |
|
44 |
def _start(self): |
45 |
- |
46 |
- distfile_path = os.path.join( |
47 |
- self.config.options.distfiles, |
48 |
- self.config.layouts[0].get_path(self.distfile)) |
49 |
- |
50 |
if self.config.options.recycle_dir is not None: |
51 |
recycle_path = os.path.join( |
52 |
self.config.options.recycle_dir, self.distfile) |
53 |
@@ -29,7 +24,8 @@ class DeletionTask(CompositeTask): |
54 |
"distfiles to recycle") % self.distfile) |
55 |
try: |
56 |
# note: distfile_path can be a symlink here |
57 |
- os.rename(os.path.realpath(distfile_path), recycle_path) |
58 |
+ os.rename(os.path.realpath(self.distfile_path), |
59 |
+ recycle_path) |
60 |
except OSError as e: |
61 |
if e.errno != errno.EXDEV: |
62 |
logging.error(("rename %s from distfiles to " |
63 |
@@ -40,7 +36,7 @@ class DeletionTask(CompositeTask): |
64 |
return |
65 |
|
66 |
self._start_task( |
67 |
- FileCopier(src_path=distfile_path, |
68 |
+ FileCopier(src_path=self.distfile_path, |
69 |
dest_path=recycle_path, |
70 |
background=False), |
71 |
self._recycle_copier_exit) |
72 |
@@ -55,7 +51,7 @@ class DeletionTask(CompositeTask): |
73 |
logging.debug(("delete '%s' from " |
74 |
"distfiles") % self.distfile) |
75 |
try: |
76 |
- os.unlink(distfile_path) |
77 |
+ os.unlink(self.distfile_path) |
78 |
except OSError as e: |
79 |
if e.errno not in (errno.ENOENT, errno.ESTALE): |
80 |
logging.error("%s unlink failed in distfiles: %s" % |
81 |
-- |
82 |
2.23.0 |