[Git][reproducible-builds/diffoscope][master] 4 commits: tempfiles: set the base directory only if the caller didn't specify one already
Mattia Rizzolo
gitlab at salsa.debian.org
Sun Jul 1 21:14:57 CEST 2018
Mattia Rizzolo pushed to branch master at Reproducible Builds / diffoscope
Commits:
d6f1d04b by Mattia Rizzolo at 2018-07-01T20:51:12+02:00
tempfiles: set the base directory only if the caller didn't specify one already
Signed-off-by: Mattia Rizzolo <mattia at debian.org>
- - - - -
ef48c90f by Mattia Rizzolo at 2018-07-01T20:51:43+02:00
tempfiles: do not append '_diffoscope' to the temporary file names, as they are now all in their namespaced directory already
Signed-off-by: Mattia Rizzolo <mattia at debian.org>
- - - - -
1e8fb23d by Mattia Rizzolo at 2018-07-01T20:52:52+02:00
tempfiles: use 'diffoscope_' instead of 'diffoscope-' as prefix
I just like it more :)
Gbp-Dch: Ignore
Signed-off-by: Mattia Rizzolo <mattia at debian.org>
- - - - -
a6b4effc by Mattia Rizzolo at 2018-07-01T20:53:48+02:00
tempfiles: empty the list of known tempfiles after removing them
tempfiles would be cleaned up between tests, so the new "base directory"
would be removed as well, that made the next tentative to create a temporary
directory fail.
This is not interesting for regular execution of diffoscope, as only
programs executing diffoscope.main.main() twice within the same python
process would notice.
Closes: #902709
Signed-off-by: Mattia Rizzolo <mattia at debian.org>
- - - - -
1 changed file:
- diffoscope/tempfiles.py
Changes:
=====================================
diffoscope/tempfiles.py
=====================================
--- a/diffoscope/tempfiles.py
+++ b/diffoscope/tempfiles.py
@@ -3,6 +3,7 @@
# diffoscope: in-depth comparison of files, archives, and directories
#
# Copyright © 2016 Chris Lamb <lamby at debian.org>
+# © 2018 Mattia Rizzolo <mattia at debian.org>
#
# diffoscope is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
@@ -27,8 +28,7 @@ logger = logging.getLogger(__name__)
def get_named_temporary_file(*args, **kwargs):
- kwargs['dir'] = _get_base_temporary_directory()
- kwargs['suffix'] = kwargs.pop('suffix', '_diffoscope')
+ kwargs['dir'] = kwargs.pop('dir', _get_base_temporary_directory())
f = tempfile.NamedTemporaryFile(*args, **kwargs)
_FILES.append(f.name)
@@ -37,8 +37,7 @@ def get_named_temporary_file(*args, **kwargs):
def get_temporary_directory(*args, **kwargs):
- kwargs['dir'] = _get_base_temporary_directory()
- kwargs['suffix'] = kwargs.pop('suffix', '_diffoscope')
+ kwargs['dir'] = kwargs.pop('dir', _get_base_temporary_directory())
d = tempfile.TemporaryDirectory(*args, **kwargs)
_DIRS.append(d)
@@ -56,6 +55,7 @@ def clean_all_temp_files():
pass
except:
logger.exception("Unable to delete %s", x)
+ _FILES.clear()
logger.debug("Cleaning %d temporary directories", len(_DIRS))
@@ -76,13 +76,14 @@ def clean_all_temp_files():
pass
except:
logger.exception("Unable to delete %s", x)
+ _DIRS.clear()
def _get_base_temporary_directory():
if not _DIRS:
d = tempfile.TemporaryDirectory(
dir=tempfile.gettempdir(),
- prefix='diffoscope-',
+ prefix='diffoscope_',
)
logger.debug("Created top-level temporary directory: %s", d.name)
View it on GitLab: https://salsa.debian.org/reproducible-builds/diffoscope/compare/d82ec13b37cf9c0c24275a724b46c2a3e7d82a05...a6b4effcfb24780d9d2d1b76efa33132381f76eb
--
View it on GitLab: https://salsa.debian.org/reproducible-builds/diffoscope/compare/d82ec13b37cf9c0c24275a724b46c2a3e7d82a05...a6b4effcfb24780d9d2d1b76efa33132381f76eb
You're receiving this email because of your account on salsa.debian.org.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.reproducible-builds.org/pipermail/rb-commits/attachments/20180701/2555a0cf/attachment.html>
More information about the rb-commits
mailing list