1
0
mirror of https://github.com/moparisthebest/pacman synced 2024-08-13 17:03:46 -04:00

Add configuration option to control disk space checking

Disk space checking is likely to be an unnecessary bottleneck to
people with reasonable partition sizes so add a configuration option
to allow it to be disabled/enabled as wanted.

Signed-off-by: Allan McRae <allan@archlinux.org>
Signed-off-by: Dan McGee <dan@archlinux.org>
This commit is contained in:
Allan McRae 2010-11-16 16:54:30 +10:00 committed by Dan McGee
parent 3f0d98c124
commit e22aa23c8f
7 changed files with 31 additions and 4 deletions

View File

@ -162,6 +162,10 @@ Options
than the percent of each individual download target. The progress
bar is still based solely on the current file download.
*CheckSpace*::
Performs an approximate check for adequate available disk space before
installing packages.
Repository Sections
-------------------
Each repository section defines a section name and at least one location where

View File

@ -33,6 +33,7 @@ Architecture = auto
#ShowSize
#UseDelta
#TotalDownload
#CheckSpace
#
# REPOSITORIES

View File

@ -155,6 +155,9 @@ void alpm_option_set_arch(const char *arch);
int alpm_option_get_usedelta();
void alpm_option_set_usedelta(int usedelta);
int alpm_option_get_checkspace();
void alpm_option_set_checkspace(int checkspace);
pmdb_t *alpm_option_get_localdb();
alpm_list_t *alpm_option_get_syncdbs();

View File

@ -232,6 +232,15 @@ int SYMEXPORT alpm_option_get_usedelta()
return handle->usedelta;
}
int SYMEXPORT alpm_option_get_checkspace()
{
if (handle == NULL) {
pm_errno = PM_ERR_HANDLE_NULL;
return -1;
}
return handle->checkspace;
}
pmdb_t SYMEXPORT *alpm_option_get_localdb()
{
if (handle == NULL) {
@ -550,4 +559,9 @@ void SYMEXPORT alpm_option_set_usedelta(int usedelta)
handle->usedelta = usedelta;
}
void SYMEXPORT alpm_option_set_checkspace(int checkspace)
{
handle->checkspace = checkspace;
}
/* vim: set ts=2 sw=2 noet: */

View File

@ -60,6 +60,7 @@ typedef struct _pmhandle_t {
int usesyslog; /* Use syslog instead of logfile? */ /* TODO move to frontend */
char *arch; /* Architecture of packages we should allow */
int usedelta; /* Download deltas if possible */
int checkspace; /* Check disk space before installing */
} pmhandle_t;
/* global handle variable */

View File

@ -998,11 +998,13 @@ int _alpm_sync_commit(pmtrans_t *trans, pmdb_t *db_local, alpm_list_t **data)
}
/* check available disk space */
if(handle->checkspace) {
_alpm_log(PM_LOG_DEBUG, "checking available disk space\n");
if(_alpm_check_diskspace(trans, handle->db_local) == -1) {
_alpm_log(PM_LOG_ERROR, _("not enough free disk space\n"));
goto error;
}
}
/* remove conflicting and to-be-replaced packages */
if(replaces) {

View File

@ -956,6 +956,8 @@ static int _parse_options(char *key, char *value)
} else if(strcmp(key, "TotalDownload") == 0) {
config->totaldownload = 1;
pm_printf(PM_LOG_DEBUG, "config: totaldownload\n");
} else if(strcmp(key, "CheckSpace") == 0) {
alpm_option_set_checkspace(1);
} else {
pm_printf(PM_LOG_ERROR, _("directive '%s' without value not recognized\n"), key);
return(1);