Together with the temporary files removal, let's also remove the directories created to store those files.
Signed-off-by: Fabiano Fidêncio <fiden...@redhat.com> --- virtinst/installer.py | 10 ++++++++++ virtinst/installertreemedia.py | 9 +++++++++ 2 files changed, 19 insertions(+) diff --git a/virtinst/installer.py b/virtinst/installer.py index ca23d526..24653d3c 100644 --- a/virtinst/installer.py +++ b/virtinst/installer.py @@ -140,10 +140,20 @@ class Installer(object): self._install_floppy_device.sync_path_props() def _cleanup_unattended_files(self): + dirs = [] for f in self._unattended_files: + dirname = os.path.dirname(f) + if dirname not in dirs: + dirs.append(dirname) + logging.debug("Removing %s", str(f)) os.unlink(f) + for d in dirs: + if not os.listdir(d): + logging.debug("Removing %s", str(d)) + os.rmdir(d) + def _build_boot_order(self, guest, bootdev): bootorder = [bootdev] diff --git a/virtinst/installertreemedia.py b/virtinst/installertreemedia.py index ea522904..d7fef898 100644 --- a/virtinst/installertreemedia.py +++ b/virtinst/installertreemedia.py @@ -208,10 +208,19 @@ class InstallerTreeMedia(object): def cleanup(self, guest): ignore = guest + dirs = [] for f in self._tmpfiles: + dirname = os.path.dirname(f) + if dirname not in dirs: + dirs.append(dirname) logging.debug("Removing %s", str(f)) os.unlink(f) + for d in dirs: + if not os.listdir(d): + logging.debug("Removing %s", d) + os.rmdir(d) + for vol in self._tmpvols: logging.debug("Removing volume '%s'", vol.name()) vol.delete(0) -- 2.21.0 _______________________________________________ virt-tools-list mailing list virt-tools-list@redhat.com https://www.redhat.com/mailman/listinfo/virt-tools-list