Discussion:
[LIBREPORT PATCH] print warning when there is not engough free space for debuginfos, closes #170
Petr Kubat
2013-08-28 14:22:41 UTC
Permalink
Signed-off-by: Petr Kubat <pkubat-H+wXaHxf7aLQT0dZR+***@public.gmane.org>
---
src/client-python/debuginfo.py | 23 +++++++++++++++++++++++
1 file changed, 23 insertions(+)

diff --git a/src/client-python/debuginfo.py b/src/client-python/debuginfo.py
index 035d697..68fe6e0 100644
--- a/src/client-python/debuginfo.py
+++ b/src/client-python/debuginfo.py
@@ -324,6 +324,29 @@ class DebugInfoDownload(YumBase):
if self.noninteractive == False and not ask_yes_no(question):
print _("Download cancelled by user")
return RETURN_CANCEL_BY_USER
+ # set up tmp and cache dirs so that we can check free space in both
+ retval = self.setup_tmp_dirs()
+ if retval != RETURN_OK:
+ return retval
+ # check if there is enough free space in both tmp and cache
+ res = os.statvfs(self.tmpdir)
+ tmp_space = float(res.f_bsize * res.f_bavail) / (1024*1024)
+ if (todownload_size / (1024*1024)) > tmp_space:
+ question = _("Warning: Not enough free space in tmp dir '{0}'"
+ " ({1:.2f}Mb left). Continue?").format(
+ self.tmpdir, tmp_space)
+ if not self.noninteractive and not ask_yes_no(question):
+ print _("Download cancelled by user")
+ return RETURN_CANCEL_BY_USER
+ res = os.statvfs(self.cachedir)
+ cache_space = float(res.f_bsize * res.f_bavail) / (1024*1024)
+ if (installed_size / (1024*1024)) > cache_space:
+ question = _("Warning: Not enough free space in cache dir "
+ "'{0}' ({1:.2f}Mb left). Continue?").format(
+ self.cachedir, cache_space)
+ if not self.noninteractive and not ask_yes_no(question):
+ print _("Download cancelled by user")
+ return RETURN_CANCEL_BY_USER

for pkg, files in package_files_dict.iteritems():
dnlcb.downloaded_pkgs = downloaded_pkgs
--
1.8.3.1
Richard Marko
2013-08-28 14:36:29 UTC
Permalink
Thanks. Pushed.

Looks like that code in that file should be improved a bit.. :(
Post by Petr Kubat
---
src/client-python/debuginfo.py | 23 +++++++++++++++++++++++
1 file changed, 23 insertions(+)
diff --git a/src/client-python/debuginfo.py b/src/client-python/debuginfo.py
index 035d697..68fe6e0 100644
--- a/src/client-python/debuginfo.py
+++ b/src/client-python/debuginfo.py
print _("Download cancelled by user")
return RETURN_CANCEL_BY_USER
+ # set up tmp and cache dirs so that we can check free space in both
+ retval = self.setup_tmp_dirs()
+ return retval
+ # check if there is enough free space in both tmp and cache
+ res = os.statvfs(self.tmpdir)
+ tmp_space = float(res.f_bsize * res.f_bavail) / (1024*1024)
+ question = _("Warning: Not enough free space in tmp dir '{0}'"
+ " ({1:.2f}Mb left). Continue?").format(
+ self.tmpdir, tmp_space)
+ print _("Download cancelled by user")
+ return RETURN_CANCEL_BY_USER
+ res = os.statvfs(self.cachedir)
+ cache_space = float(res.f_bsize * res.f_bavail) / (1024*1024)
+ question = _("Warning: Not enough free space in cache dir "
+ "'{0}' ({1:.2f}Mb left). Continue?").format(
+ self.cachedir, cache_space)
+ print _("Download cancelled by user")
+ return RETURN_CANCEL_BY_USER
dnlcb.downloaded_pkgs = downloaded_pkgs
--
Richard Marko
Loading...