[PATCH] fix: if the DL_DIR environment variable is set use it on cleanall

2 views
Skip to first unread message

Dan Ambrosio

unread,
Nov 18, 2025, 12:02:28 PMNov 18
to kas-...@googlegroups.com
I noticed that kas cleanall was not removing files in my ${HOME}/.cache/kas/downloads directory. I provide this directory to kas using the DL_DIR environment variable.

After reviewing the CleanAll plugin class, the downloads_dir variable only uses Path(ctx.build_dir) / 'downloads', instead of checking if the DL_DIR environment variable is set.

This patch updates the run function in the CleanAll class to check if the DL_DIR is set, and uses its value as the Path used when performing cleanup.

Signed-off-by: Dan Ambrosio <dan.am...@gmail.com>
---
 kas/plugins/clean.py | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/kas/plugins/clean.py b/kas/plugins/clean.py
index af6a77a..9313d29 100644
--- a/kas/plugins/clean.py
+++ b/kas/plugins/clean.py
@@ -158,7 +158,8 @@ class CleanAll(CleanSstate):
     def run(self, args):
         super().run(args)
         ctx = get_context()
-        downloads_dir = Path(ctx.build_dir) / 'downloads'
+        downloads_dir = Path(os.environ.get('DL_DIR',
+                                            Path(ctx.build_dir) / 'downloads'))
         if downloads_dir.exists():
             logging.info(f'Removing {downloads_dir}/*')
             if not args.dry_run:
--
2.34.1

Jan Kiszka

unread,
Nov 18, 2025, 1:04:10 PMNov 18
to Dan Ambrosio, kas-...@googlegroups.com
"use DL_DIR environment variable on cleanall"

On 18.11.25 18:02, Dan Ambrosio wrote:
> I noticed that kas cleanall was not removing files in my ${HOME}/.cache/
> kas/downloads directory. I provide this directory to kas using the
> DL_DIR environment variable.
>
> After reviewing the CleanAll plugin class, the downloads_dir variable
> only uses Path(ctx.build_dir) / 'downloads', instead of checking if the
> DL_DIR environment variable is set.
>

Neutral style preferred over first person: "kas cleanall was not
removing file in the directory provided via DL_DIR. This patch..."

> This patch updates the run function in the CleanAll class to check if
> the DL_DIR is set, and uses its value as the Path used when performing
> cleanup.
>
> Signed-off-by: Dan Ambrosio <dan.am...@gmail.com
> <mailto:dan.am...@gmail.com>>
> ---
>  kas/plugins/clean.py | 3 ++-
>  1 file changed, 2 insertions(+), 1 deletion(-)
>
> diff --git a/kas/plugins/clean.py b/kas/plugins/clean.py
> index af6a77a..9313d29 100644
> --- a/kas/plugins/clean.py
> +++ b/kas/plugins/clean.py
> @@ -158,7 +158,8 @@ class CleanAll(CleanSstate):
>      def run(self, args):
>          super().run(args)
>          ctx = get_context()
> -        downloads_dir = Path(ctx.build_dir) / 'downloads'
> +        downloads_dir = Path(os.environ.get('DL_DIR',
> +                                            Path(ctx.build_dir) /
> 'downloads'))

I'm pretty sure, scripts/checkcode.sh will bark at this...

>          if downloads_dir.exists():
>              logging.info <http://logging.info>(f'Removing
> {downloads_dir}/*')
>              if not args.dry_run:
> --
> 2.34.1
>

Thanks for this fix!

Jan

--
Siemens AG, Foundational Technologies
Linux Expert Center

Dan Ambrosio

unread,
Nov 18, 2025, 1:16:49 PMNov 18
to Jan Kiszka, kas-...@googlegroups.com
Jan,

Do you need me to do anything else with this related to the neutral style?

Running scripts/checkcode.sh passed for me:

./scripts/checkcode.sh
Checking with pycodestyle
Checking with flake8
Checking with doc8
Scanning...
Validating...
========
Total files scanned = 31
Total files ignored = 0
Total accumulated errors = 0
Detailed error counts:
    - doc8.checks.CheckCarriageReturn = 0
    - doc8.checks.CheckIndentationNoTab = 0
    - doc8.checks.CheckMaxLineLength = 0
    - doc8.checks.CheckNewlineEndOfFile = 0
    - doc8.checks.CheckTrailingWhitespace = 0
    - doc8.checks.CheckValidity = 0
Checking with shellcheck
echo $?
0

Thanks
--
Daniel Ambrosio
email: dan.am...@gmail.com

Jan Kiszka

unread,
Nov 18, 2025, 2:31:17 PMNov 18
to Dan Ambrosio, kas-...@googlegroups.com
On 18.11.25 19:16, Dan Ambrosio wrote:
> Jan,
>
> Do you need me to do anything else with this related to the neutral style?
>

I can fix this up while merging.

> Running scripts/checkcode.sh passed for me:
>
> ./scripts/checkcode.sh
> Checking with pycodestyle
> Checking with flake8
> Checking with doc8
> Scanning...
> Validating...
> ========
> Total files scanned = 31
> Total files ignored = 0
> Total accumulated errors = 0
> Detailed error counts:
>     - doc8.checks.CheckCarriageReturn = 0
>     - doc8.checks.CheckIndentationNoTab = 0
>     - doc8.checks.CheckMaxLineLength = 0
>     - doc8.checks.CheckNewlineEndOfFile = 0
>     - doc8.checks.CheckTrailingWhitespace = 0
>     - doc8.checks.CheckValidity = 0
> Checking with shellcheck
> echo $?
> 0
>

Hmm, triggers for me, but on something unrelated. I just guess there is
a too long line, but the html formatted email misguided me ("git
sendemail" would have avoided that formatting issue).

Thanks again, merged with commit message adjustments.

Jan

> Thanks
>
> On Tue, Nov 18, 2025 at 11:04 AM Jan Kiszka <jan.k...@siemens.com
> <mailto:jan.k...@siemens.com>> wrote:
>
> "use DL_DIR environment variable on cleanall"
>
> On 18.11.25 18:02, Dan Ambrosio wrote:
> > I noticed that kas cleanall was not removing files in my
> ${HOME}/.cache/
> > kas/downloads directory. I provide this directory to kas using the
> > DL_DIR environment variable.
> >
> > After reviewing the CleanAll plugin class, the downloads_dir variable
> > only uses Path(ctx.build_dir) / 'downloads', instead of checking
> if the
> > DL_DIR environment variable is set.
> >
>
> Neutral style preferred over first person: "kas cleanall was not
> removing file in the directory provided via DL_DIR. This patch..."
>
> > This patch updates the run function in the CleanAll class to check if
> > the DL_DIR is set, and uses its value as the Path used when performing
> > cleanup.
> >
> > Signed-off-by: Dan Ambrosio <dan.am...@gmail.com
> <mailto:dan.am...@gmail.com>
> > <mailto:dan.am...@gmail.com <mailto:dan.am...@gmail.com>>>
> > ---
> >  kas/plugins/clean.py | 3 ++-
> >  1 file changed, 2 insertions(+), 1 deletion(-)
> >
> > diff --git a/kas/plugins/clean.py b/kas/plugins/clean.py
> > index af6a77a..9313d29 100644
> > --- a/kas/plugins/clean.py
> > +++ b/kas/plugins/clean.py
> > @@ -158,7 +158,8 @@ class CleanAll(CleanSstate):
> >      def run(self, args):
> >          super().run(args)
> >          ctx = get_context()
> > -        downloads_dir = Path(ctx.build_dir) / 'downloads'
> > +        downloads_dir = Path(os.environ.get('DL_DIR',
> > +                                            Path(ctx.build_dir) /
> > 'downloads'))
>
> I'm pretty sure, scripts/checkcode.sh will bark at this...
>
> >          if downloads_dir.exists():
> >              logging.info <http://logging.info> <http://
> logging.info <http://logging.info>>(f'Removing
> > {downloads_dir}/*')
> >              if not args.dry_run:
> > --
> > 2.34.1
> >
>
> Thanks for this fix!
>
> Jan
>
> --
> Siemens AG, Foundational Technologies
> Linux Expert Center
>
>
>
> --
> *Daniel Ambrosio*
> email: dan.am...@gmail.com <mailto:dan.am...@gmail.com>
> ph: 303-921-6204
Reply all
Reply to author
Forward
0 new messages