[Git][reproducible-builds/diffoscope][master] 2 commits: Explicitly remove our top-level temporary directory. (Closes:...

Chris Lamb gitlab at salsa.debian.org
Thu Jan 28 12:18:28 UTC 2021



Chris Lamb pushed to branch master at Reproducible Builds / diffoscope


Commits:
797411a5 by Chris Lamb at 2021-01-28T12:14:46+00:00
Explicitly remove our top-level temporary directory. (Closes: reproducible-builds/diffoscope#234, Debian:#981123)

We cannot rely on __del__ being called determinstically, if at all, and
lets remove our top-level directory. Thanks to Dimitrios Apostolou and
Mattia Rizzolo.

This essentially reverts commit c645d403745371eca9c8f70cdf6a4f766adf1c00.

- - - - -
8a872846 by Chris Lamb at 2021-01-28T12:17:24+00:00
Print the free space in our temporary directory when we create it, not from within diffoscope.main.

- - - - -


2 changed files:

- diffoscope/main.py
- diffoscope/tempfiles.py


Changes:

=====================================
diffoscope/main.py
=====================================
@@ -38,13 +38,12 @@ from .tools import (
     OS_NAMES,
     get_current_os,
 )
-from .utils import format_bytes
 from .config import Config
 from .environ import normalize_environment
 from .logging import line_eraser, setup_logging
 from .progress import ProgressManager, Progress
 from .profiling import ProfileManager, profile
-from .tempfiles import clean_all_temp_files, get_tempdir_free_space
+from .tempfiles import clean_all_temp_files
 from .difference import Difference
 from .comparators import ComparatorManager
 from .external_tools import EXTERNAL_TOOLS, HUGE_TOOLS
@@ -686,10 +685,6 @@ def run_diffoscope(parsed_args):
     """
 
     logger.debug("Starting diffoscope %s", VERSION)
-    logger.debug(
-        "Free space in temporary directory: %s",
-        format_bytes(get_tempdir_free_space()),
-    )
 
     ProfileManager().setup(parsed_args)
     PresenterManager().configure(parsed_args)


=====================================
diffoscope/tempfiles.py
=====================================
@@ -19,9 +19,12 @@
 
 import os
 import sys
+import shutil
 import logging
 import tempfile
 
+from .utils import format_bytes
+
 _BASEDIR = None
 _FILES = []
 
@@ -74,6 +77,11 @@ def clean_all_temp_files():
             logger.exception("Unable to delete %s", x)
     _FILES.clear()
 
+    if _BASEDIR is not None:
+        logger.debug("Cleaning top-level temporary directory %s", _BASEDIR)
+
+        shutil.rmtree(_BASEDIR, ignore_errors=True)
+
 
 def _get_base_temporary_directory():
     global _BASEDIR
@@ -82,7 +90,9 @@ def _get_base_temporary_directory():
             dir=tempfile.gettempdir(), prefix="diffoscope_"
         )
         logger.debug(
-            "Created top-level temporary directory: %s", _BASEDIR.name
+            "Created top-level temporary directory: %s (free space: %s)",
+            _BASEDIR.name,
+            format_bytes(get_tempdir_free_space()),
         )
 
         with open(os.path.join(_BASEDIR.name, "argv"), "w") as f:



View it on GitLab: https://salsa.debian.org/reproducible-builds/diffoscope/-/compare/2b177b517652e62365a6597d153617ce577713e4...8a872846af1c5e9d36a0dddf6333376a794ff75e

-- 
View it on GitLab: https://salsa.debian.org/reproducible-builds/diffoscope/-/compare/2b177b517652e62365a6597d153617ce577713e4...8a872846af1c5e9d36a0dddf6333376a794ff75e
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/20210128/f5cee27c/attachment.htm>


More information about the rb-commits mailing list