summaryrefslogtreecommitdiff
path: root/lib/libalpm/sync.c
diff options
context:
space:
mode:
Diffstat (limited to 'lib/libalpm/sync.c')
-rw-r--r--lib/libalpm/sync.c27
1 files changed, 20 insertions, 7 deletions
diff --git a/lib/libalpm/sync.c b/lib/libalpm/sync.c
index 4cbaf0cb..69234cbf 100644
--- a/lib/libalpm/sync.c
+++ b/lib/libalpm/sync.c
@@ -31,7 +31,7 @@
#include <stdint.h> /* intmax_t */
#include <unistd.h>
#include <time.h>
-#include <dirent.h>
+#include <limits.h>
/* libalpm */
#include "sync.h"
@@ -39,7 +39,6 @@
#include "log.h"
#include "package.h"
#include "db.h"
-#include "cache.h"
#include "deps.h"
#include "conflict.h"
#include "trans.h"
@@ -50,6 +49,7 @@
#include "dload.h"
#include "delta.h"
#include "remove.h"
+#include "diskspace.h"
/** Check for new version of pkg in sync repos
* (only the first occurrence is considered in sync)
@@ -329,7 +329,7 @@ static int sync_target(alpm_list_t *dbs_sync, const char *target)
* @param target the name of the sync target to add
* @return 0 on success, -1 on error (pm_errno is set accordingly)
*/
-int SYMEXPORT alpm_sync_dbtarget(char *dbname, char *target)
+int SYMEXPORT alpm_sync_dbtarget(const char *dbname, const char *target)
{
alpm_list_t *i;
alpm_list_t *dbs_sync;
@@ -362,7 +362,7 @@ int SYMEXPORT alpm_sync_dbtarget(char *dbname, char *target)
* @param target the name of the sync target to add
* @return 0 on success, -1 on error (pm_errno is set accordingly)
*/
-int SYMEXPORT alpm_sync_target(char *target)
+int SYMEXPORT alpm_sync_target(const char *target)
{
alpm_list_t *dbs_sync;
@@ -549,10 +549,10 @@ int _alpm_sync_prepare(pmtrans_t *trans, pmdb_t *db_local, alpm_list_t *dbs_sync
/* if sync1 provides sync2, we remove sync2 from the targets, and vice versa */
pmdepend_t *dep1 = _alpm_splitdep(conflict->package1);
pmdepend_t *dep2 = _alpm_splitdep(conflict->package2);
- if(alpm_depcmp(sync1, dep2)) {
+ if(_alpm_depcmp(sync1, dep2)) {
rsync = sync2;
sync = sync1;
- } else if(alpm_depcmp(sync2, dep1)) {
+ } else if(_alpm_depcmp(sync2, dep1)) {
rsync = sync1;
sync = sync2;
} else {
@@ -854,7 +854,7 @@ int _alpm_sync_commit(pmtrans_t *trans, pmdb_t *db_local, alpm_list_t **data)
for(j = trans->add; j; j = j->next) {
pmpkg_t *spkg = j->data;
- if(spkg->origin == PKG_FROM_CACHE && current == spkg->origin_data.db) {
+ if(spkg->origin != PKG_FROM_FILE && current == spkg->origin_data.db) {
const char *fname = NULL;
fname = alpm_pkg_get_filename(spkg);
@@ -1018,6 +1018,19 @@ int _alpm_sync_commit(pmtrans_t *trans, pmdb_t *db_local, alpm_list_t **data)
EVENT(trans, PM_TRANS_EVT_FILECONFLICTS_DONE, NULL, NULL);
}
+ /* check available disk space */
+ if(handle->checkspace) {
+ EVENT(trans, PM_TRANS_EVT_DISKSPACE_START, NULL, NULL);
+
+ _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;
+ }
+
+ EVENT(trans, PM_TRANS_EVT_DISKSPACE_DONE, NULL, NULL);
+ }
+
/* remove conflicting and to-be-replaced packages */
if(replaces) {
_alpm_log(PM_LOG_DEBUG, "removing conflicting and to-be-replaced packages\n");