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