summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJason Woodward2009-10-17 17:52:52 -0400
committerJason Woodward2009-10-17 17:52:52 -0400
commit653b869daa3e51c317ba4e9e2337b66b9e0ed07b (patch)
treed07db88fb7edba4e95d98cdc17c6c15a79ea3922
parent2073d197f34dfca43c37587cb4032cf70dabc6fd (diff)
downloadgslapt-653b869daa3e51c317ba4e9e2337b66b9e0ed07b.tar.gz
use slapt_disk_space_check from libslapt0.5.2a
-rw-r--r--ChangeLog3
-rw-r--r--configure.in4
-rw-r--r--src/callbacks.c43
3 files changed, 18 insertions, 32 deletions
diff --git a/ChangeLog b/ChangeLog
index 4a1bc1e..b5bc14e 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,4 +1,7 @@
+0.5.2a Oct 17, 2009
+ * use slapt_disk_space_check from libslapt
+
0.5.2 Sep 14, 2009
* updated greek translation from George Vlahavas
* added file list tab in package view
diff --git a/configure.in b/configure.in
index 4ad69b1..38d525c 100644
--- a/configure.in
+++ b/configure.in
@@ -2,7 +2,7 @@ dnl Process this file with autoconf to produce a configure script.
AC_INIT
AC_CONFIG_SRCDIR([configure.in])
-AM_INIT_AUTOMAKE(gslapt, 0.5.2)
+AM_INIT_AUTOMAKE(gslapt, 0.5.2a)
AM_CONFIG_HEADER(config.h)
AM_MAINTAINER_MODE
@@ -40,7 +40,7 @@ AC_CHECK_LIB(gpgme,gpgme_new, [
[AC_MSG_WARN(libslapt does not have gpgme support)])
], [AC_MSG_WARN(gpg support disabled)])
dnl AC_CHECK_MEMBER([slapt_rc_config.use_priority], [LIBS="$LIBS -lslapt"], [AC_MSG_ERROR([libslapt 0.10.2 or greater is required])], [[#include <slapt.h>]])
-AC_CHECK_LIB(slapt,slapt_get_pkg_filelist, [], [AC_MSG_ERROR(libslapt 0.10.2a or greater is required)])
+AC_CHECK_LIB(slapt,slapt_disk_space_check, [], [AC_MSG_ERROR(libslapt 0.10.2b or greater is required)])
LIBS="$LIBS -lglib-2.0 -lgthread-2.0"
diff --git a/src/callbacks.c b/src/callbacks.c
index bf2840e..cce8c6f 100644
--- a/src/callbacks.c
+++ b/src/callbacks.c
@@ -44,7 +44,6 @@ static gboolean sources_modified = FALSE;
static gboolean excludes_modified = FALSE;
static volatile guint pending_trans_context_id = 0;
-static int disk_space(int space_needed);
static gboolean pkg_action_popup_menu (GtkTreeView *treeview, gpointer data);
static int set_iter_to_pkg (GtkTreeModel *model, GtkTreeIter *iter,
slapt_pkg_info_t *pkg);
@@ -1712,7 +1711,7 @@ static int populate_transaction_window (GtkWidget *trans_window)
GtkTreeViewColumn *column;
GtkLabel *sum_pkg_num,*sum_dl_size,*sum_free_space;
guint i;
- gint dl_size = 0,free_space = 0,already_dl_size = 0;
+ double dl_size = 0,free_space = 0,already_dl_size = 0;
gchar buf[512];
summary_treeview = GTK_TREE_VIEW(lookup_widget(trans_window,"transaction_summary_treeview"));
@@ -1850,15 +1849,20 @@ static int populate_transaction_window (GtkWidget *trans_window)
);
gtk_label_set_text(GTK_LABEL(sum_pkg_num),buf);
- /* if we don't have enough free space */
- if (disk_space(dl_size - already_dl_size + free_space) != 0) {
+ /* if we don't have enough free space to download */
+ if (slapt_disk_space_check(global_config->working_dir,dl_size - already_dl_size) == SLAPT_FALSE) {
+ notify((gchar *)_("Error"),(gchar *)_("<span weight=\"bold\" size=\"large\">You don't have enough free space</span>"));
+ return -1;
+ }
+ /* if we don't have enough free space to install on / */
+ if (slapt_disk_space_check("/",free_space) == SLAPT_FALSE) {
notify((gchar *)_("Error"),(gchar *)_("<span weight=\"bold\" size=\"large\">You don't have enough free space</span>"));
return -1;
}
if ( already_dl_size > 0 ) {
- int need_to_dl = dl_size - already_dl_size;
- snprintf(buf,512,(gchar *)_("Need to get %.1d%s/%.1d%s of archives.\n"),
+ double need_to_dl = dl_size - already_dl_size;
+ snprintf(buf,512,(gchar *)_("Need to get %.0f%s/%.0f%s of archives.\n"),
(need_to_dl > 1024 ) ? need_to_dl / 1024
: need_to_dl,
(need_to_dl > 1024 ) ? "MB" : "kB",
@@ -1866,7 +1870,7 @@ static int populate_transaction_window (GtkWidget *trans_window)
(dl_size > 1024 ) ? "MB" : "kB"
);
}else{
- snprintf(buf,512,(gchar *)_("Need to get %.1d%s of archives."),
+ snprintf(buf,512,(gchar *)_("Need to get %.0f%s of archives."),
(dl_size > 1024 ) ? dl_size / 1024 : dl_size,
(dl_size > 1024 ) ? "MB" : "kB"
);
@@ -1875,13 +1879,13 @@ static int populate_transaction_window (GtkWidget *trans_window)
if ( free_space < 0 ) {
free_space *= -1;
- snprintf(buf,512,(gchar *)_("After unpacking %.1d%s disk space will be freed."),
+ snprintf(buf,512,(gchar *)_("After unpacking %.0f%s disk space will be freed."),
(free_space > 1024 ) ? free_space / 1024
: free_space,
(free_space > 1024 ) ? "MB" : "kB"
);
}else{
- snprintf(buf,512,(gchar *)_("After unpacking %.1d%s of additional disk space will be used."),
+ snprintf(buf,512,(gchar *)_("After unpacking %.0f%s of additional disk space will be used."),
(free_space > 1024 ) ? free_space / 1024 : free_space,
(free_space > 1024 ) ? "MB" : "kB"
);
@@ -2481,27 +2485,6 @@ static void notify (const char *title,const char *message)
gtk_widget_show(w);
}
-static int disk_space (int space_needed)
-{
- struct statvfs statvfs_buf;
-
- space_needed *= 1024;
-
- if (space_needed < 0)
- return 0;
-
- if (statvfs(global_config->working_dir,&statvfs_buf) != 0) {
- if (errno)
- perror("statvfs");
- return 1;
- } else {
- if (statvfs_buf.f_bfree < (space_needed / statvfs_buf.f_bsize))
- return 1;
- }
-
- return 0;
-}
-
static gboolean pkg_action_popup_menu (GtkTreeView *treeview, gpointer data)
{
GtkMenu *menu;