Send patches - preferably formatted by git format-patch - to patches at archlinux32 dot org.
summaryrefslogtreecommitdiff
path: root/lib/libalpm
diff options
context:
space:
mode:
authorDan McGee <dan@archlinux.org>2011-09-02 19:26:07 -0500
committerDan McGee <dan@archlinux.org>2011-09-02 19:26:07 -0500
commit83a1e4fee39321358858841069e1fe36d44edefc (patch)
tree9638a56a69aa45c071dd3934dfcb2b9fca8e5791 /lib/libalpm
parentc51b9ca0ad897428a008701e35f8f11fa0ad9046 (diff)
Clean up handling of size fields
We currently have csize, isize, and size concepts, and sometimes the difference isn't clear. Ensure the following holds: * size (aka csize): always the compressed size of the package; available for everything except local packages (where it will return 0) * isize: always the installed size of the package; available for all three package types Signed-off-by: Dan McGee <dan@archlinux.org>
Diffstat (limited to 'lib/libalpm')
-rw-r--r--lib/libalpm/alpm.h3
-rw-r--r--lib/libalpm/be_local.c16
-rw-r--r--lib/libalpm/be_sync.c8
-rw-r--r--lib/libalpm/delta.c7
-rw-r--r--lib/libalpm/package.c5
-rw-r--r--lib/libalpm/package.h1
-rw-r--r--lib/libalpm/sync.c13
7 files changed, 13 insertions, 40 deletions
diff --git a/lib/libalpm/alpm.h b/lib/libalpm/alpm.h
index 42e60385..cfc2a100 100644
--- a/lib/libalpm/alpm.h
+++ b/lib/libalpm/alpm.h
@@ -653,7 +653,8 @@ const char *alpm_pkg_get_sha256sum(alpm_pkg_t *pkg);
*/
const char *alpm_pkg_get_arch(alpm_pkg_t *pkg);
-/** Returns the size of the package.
+/** Returns the size of the package. This is only available for sync database
+ * packages and package files, not those loaded from the local database.
* @param pkg a pointer to package
* @return the size of the package in bytes.
*/
diff --git a/lib/libalpm/be_local.c b/lib/libalpm/be_local.c
index dc9e361d..ba415448 100644
--- a/lib/libalpm/be_local.c
+++ b/lib/libalpm/be_local.c
@@ -99,12 +99,6 @@ static const char *_cache_get_arch(alpm_pkg_t *pkg)
return pkg->arch;
}
-static off_t _cache_get_size(alpm_pkg_t *pkg)
-{
- LAZY_LOAD(INFRQ_DESC, -1);
- return pkg->size;
-}
-
static off_t _cache_get_isize(alpm_pkg_t *pkg)
{
LAZY_LOAD(INFRQ_DESC, -1);
@@ -243,7 +237,6 @@ static struct pkg_operations local_pkg_ops = {
.get_installdate = _cache_get_installdate,
.get_packager = _cache_get_packager,
.get_arch = _cache_get_arch,
- .get_size = _cache_get_size,
.get_isize = _cache_get_isize,
.get_reason = _cache_get_reason,
.has_scriptlet = _cache_has_scriptlet,
@@ -621,15 +614,8 @@ static int local_db_read(alpm_pkg_t *info, alpm_dbinfrq_t inforeq)
READ_NEXT();
info->reason = (alpm_pkgreason_t)atoi(line);
} else if(strcmp(line, "%SIZE%") == 0) {
- /* NOTE: the CSIZE and SIZE fields both share the "size" field
- * in the pkginfo_t struct. This can be done b/c CSIZE
- * is currently only used in sync databases, and SIZE is
- * only used in local databases.
- */
READ_NEXT();
- info->size = _alpm_strtoofft(line);
- /* also store this value to isize */
- info->isize = info->size;
+ info->isize = _alpm_strtoofft(line);
} else if(strcmp(line, "%REPLACES%") == 0) {
READ_AND_SPLITDEP(info->replaces);
} else if(strcmp(line, "%DEPENDS%") == 0) {
diff --git a/lib/libalpm/be_sync.c b/lib/libalpm/be_sync.c
index 982d3556..7eb2539b 100644
--- a/lib/libalpm/be_sync.c
+++ b/lib/libalpm/be_sync.c
@@ -561,16 +561,8 @@ static int sync_db_read(alpm_db_t *db, struct archive *archive,
} else if(strcmp(line, "%PACKAGER%") == 0) {
READ_AND_STORE(pkg->packager);
} else if(strcmp(line, "%CSIZE%") == 0) {
- /* Note: the CSIZE and SIZE fields both share the "size" field in the
- * pkginfo_t struct. This can be done b/c CSIZE is currently only used
- * in sync databases, and SIZE is only used in local databases.
- */
READ_NEXT();
pkg->size = _alpm_strtoofft(line);
- /* also store this value to isize if isize is unset */
- if(pkg->isize == 0) {
- pkg->isize = pkg->size;
- }
} else if(strcmp(line, "%ISIZE%") == 0) {
READ_NEXT();
pkg->isize = _alpm_strtoofft(line);
diff --git a/lib/libalpm/delta.c b/lib/libalpm/delta.c
index c88955f7..1dd2bf44 100644
--- a/lib/libalpm/delta.c
+++ b/lib/libalpm/delta.c
@@ -249,12 +249,11 @@ static alpm_list_t *find_unused(alpm_list_t *deltas, const char *to, off_t quota
alpm_list_t SYMEXPORT *alpm_pkg_unused_deltas(alpm_pkg_t *pkg)
{
- off_t pkgsize = alpm_pkg_get_size(pkg);
- alpm_list_t *unused = find_unused(
+ ASSERT(pkg != NULL, return NULL);
+ return find_unused(
alpm_pkg_get_deltas(pkg),
alpm_pkg_get_filename(pkg),
- pkgsize * MAX_DELTA_RATIO);
- return unused;
+ pkg->size * MAX_DELTA_RATIO);
}
/** @} */
diff --git a/lib/libalpm/package.c b/lib/libalpm/package.c
index 487b56d9..56788808 100644
--- a/lib/libalpm/package.c
+++ b/lib/libalpm/package.c
@@ -92,7 +92,6 @@ static time_t _pkg_get_builddate(alpm_pkg_t *pkg) { return pkg->builddate
static time_t _pkg_get_installdate(alpm_pkg_t *pkg) { return pkg->installdate; }
static const char *_pkg_get_packager(alpm_pkg_t *pkg) { return pkg->packager; }
static const char *_pkg_get_arch(alpm_pkg_t *pkg) { return pkg->arch; }
-static off_t _pkg_get_size(alpm_pkg_t *pkg) { return pkg->size; }
static off_t _pkg_get_isize(alpm_pkg_t *pkg) { return pkg->isize; }
static alpm_pkgreason_t _pkg_get_reason(alpm_pkg_t *pkg) { return pkg->reason; }
static int _pkg_has_scriptlet(alpm_pkg_t *pkg) { return pkg->scriptlet; }
@@ -138,7 +137,6 @@ struct pkg_operations default_pkg_ops = {
.get_installdate = _pkg_get_installdate,
.get_packager = _pkg_get_packager,
.get_arch = _pkg_get_arch,
- .get_size = _pkg_get_size,
.get_isize = _pkg_get_isize,
.get_reason = _pkg_get_reason,
.has_scriptlet = _pkg_has_scriptlet,
@@ -258,8 +256,7 @@ const char SYMEXPORT *alpm_pkg_get_arch(alpm_pkg_t *pkg)
off_t SYMEXPORT alpm_pkg_get_size(alpm_pkg_t *pkg)
{
ASSERT(pkg != NULL, return -1);
- pkg->handle->pm_errno = 0;
- return pkg->ops->get_size(pkg);
+ return pkg->size;
}
off_t SYMEXPORT alpm_pkg_get_isize(alpm_pkg_t *pkg)
diff --git a/lib/libalpm/package.h b/lib/libalpm/package.h
index 5962b1d0..4680375a 100644
--- a/lib/libalpm/package.h
+++ b/lib/libalpm/package.h
@@ -49,7 +49,6 @@ struct pkg_operations {
time_t (*get_installdate) (alpm_pkg_t *);
const char *(*get_packager) (alpm_pkg_t *);
const char *(*get_arch) (alpm_pkg_t *);
- off_t (*get_size) (alpm_pkg_t *);
off_t (*get_isize) (alpm_pkg_t *);
alpm_pkgreason_t (*get_reason) (alpm_pkg_t *);
int (*has_scriptlet) (alpm_pkg_t *);
diff --git a/lib/libalpm/sync.c b/lib/libalpm/sync.c
index 023ad621..7106fafe 100644
--- a/lib/libalpm/sync.c
+++ b/lib/libalpm/sync.c
@@ -304,24 +304,23 @@ static int compute_download_size(alpm_pkg_t *newpkg)
size = 0;
} else if(handle->usedelta) {
off_t dltsize;
- off_t pkgsize = alpm_pkg_get_size(newpkg);
dltsize = _alpm_shortest_delta_path(handle,
alpm_pkg_get_deltas(newpkg),
alpm_pkg_get_filename(newpkg),
&newpkg->delta_path);
- if(newpkg->delta_path && (dltsize < pkgsize * MAX_DELTA_RATIO)) {
+ if(newpkg->delta_path && (dltsize < newpkg->size * MAX_DELTA_RATIO)) {
_alpm_log(handle, ALPM_LOG_DEBUG, "using delta size\n");
size = dltsize;
} else {
_alpm_log(handle, ALPM_LOG_DEBUG, "using package size\n");
- size = alpm_pkg_get_size(newpkg);
+ size = newpkg->size;
alpm_list_free(newpkg->delta_path);
newpkg->delta_path = NULL;
}
} else {
- size = alpm_pkg_get_size(newpkg);
+ size = newpkg->size;
}
_alpm_log(handle, ALPM_LOG_DEBUG, "setting download size %jd for pkg %s\n",
@@ -833,7 +832,7 @@ static int download_files(alpm_handle_t *handle, alpm_list_t **deltas)
ASSERT(spkg->filename != NULL, RET_ERR(handle, ALPM_ERR_PKG_INVALID_NAME, -1));
CALLOC(payload, 1, sizeof(*payload), RET_ERR(handle, ALPM_ERR_MEMORY, -1));
STRDUP(payload->remote_name, spkg->filename, RET_ERR(handle, ALPM_ERR_MEMORY, -1));
- payload->max_size = alpm_pkg_get_size(spkg);
+ payload->max_size = spkg->size;
files = alpm_list_add(files, payload);
}
@@ -916,7 +915,7 @@ int _alpm_sync_commit(alpm_handle_t *handle, alpm_list_t **data)
for(i = trans->add; i; i = i->next, current++) {
alpm_pkg_t *spkg = i->data;
if(spkg->origin != PKG_FROM_FILE) {
- total_bytes += alpm_pkg_get_size(spkg);
+ total_bytes += spkg->size;
}
}
/* this can only happen maliciously */
@@ -942,7 +941,7 @@ int _alpm_sync_commit(alpm_handle_t *handle, alpm_list_t **data)
continue; /* pkg_load() has been already called, this package is valid */
}
- current_bytes += alpm_pkg_get_size(spkg);
+ current_bytes += spkg->size;
filename = alpm_pkg_get_filename(spkg);
filepath = _alpm_filecache_find(handle, filename);
alpm_db_t *sdb = alpm_pkg_get_db(spkg);