mirror of
https://github.com/clearlinux/swupd-server.git
synced 2026-09-06 05:31:45 +00:00
Calculate entire contentsize for manifest
Instead of only calculating the contentsize for files that were updated in the current version (an inaccurate number for download size since this is not the compressed size), calculate for all files in the manifest. Additionally, do not add submanifest contentsizes to the current manifest contentsize, as this will result in overcount on client systems when multiple bundles include the same bundle. With this change the contentsize field of the manifests will only report the size of the files unique to that bundle. It is then the client's responsibility to calculate total bundle size including included bundles. This is reasonably easy to accomplish with the upcoming swupd-client bundle-list --deps feature. Although the above use case is a bit more work for the client, it additionally allows a user to calculate the installation size of multiple bundles much more easily, since it only has to count bundle dependencies once to ensure files are not over counted. If two bundles not in the same include chain have overlapping content, summing the include chain of each bundle in the client will result in an over-estimation of the total size on the system. The more content is shared, the higher the over-estimation. In reality this overlap will not be large, but it is currently impossible to calculate the exact installed size using just the contentsize. Signed-off-by: Matthew Johnson <matthew.johnson@intel.com>
This commit is contained in:
+14
-15
@@ -675,19 +675,29 @@ char *file_type_to_string(struct file *file)
|
||||
return type;
|
||||
}
|
||||
|
||||
/* Calculate the contentsize for the manifest based on file sizes.
|
||||
*
|
||||
* This should calculate the files uniquely included in this manifest, but none
|
||||
* of its submanifests, which will allow calculation of sizes of all bundles on
|
||||
* a system by adding all manifest->contentsizes of installed bundles.
|
||||
*
|
||||
* However, if two bundles not in the same include chain have overlapping
|
||||
* content, summing the include chain of each bundle in the client will result
|
||||
* in an over-estimation of the total size on the system. The more content is
|
||||
* shared, the higher the over-estimation. In reality this overlap will not be
|
||||
* large, but it is currently impossible to calculate the exact installed size
|
||||
* using just the contentsize.
|
||||
*/
|
||||
static void compute_content_size(struct manifest *manifest)
|
||||
{
|
||||
/* FIXME: this is a temporary implementation based on worst case */
|
||||
|
||||
GList *list;
|
||||
struct file *file;
|
||||
struct manifest *submanifest;
|
||||
|
||||
list = g_list_first(manifest->files);
|
||||
while (list) {
|
||||
file = list->data;
|
||||
list = g_list_next(list);
|
||||
if (!file->is_deleted && (file->last_change == manifest->version)) {
|
||||
if (!file->is_deleted) {
|
||||
if (file->is_file) {
|
||||
manifest->contentsize += file->stat.st_size;
|
||||
} else if (file->is_link) {
|
||||
@@ -697,17 +707,6 @@ static void compute_content_size(struct manifest *manifest)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
list = g_list_first(manifest->submanifests);
|
||||
while (list) {
|
||||
submanifest = list->data;
|
||||
list = g_list_next(list);
|
||||
|
||||
/* Do not take into account groups not included in download content */
|
||||
if (create_download_content_for_group(submanifest->component)) {
|
||||
manifest->contentsize += submanifest->contentsize;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/* Returns 0 == success, -1 == failure */
|
||||
|
||||
Reference in New Issue
Block a user