mirror of
https://github.com/clearlinux/swupd-client.git
synced 2026-10-03 15:29:29 +00:00
Skip verified unchanged files in update
Instead of just checking if the versions have changed for a file to be updated, compare the current file's hash to updated file's expected hash and only queue files for update that are changed.
This commit is contained in:
committed by
Patrick McCarty
parent
a5632aba0d
commit
4b522b352a
@@ -174,6 +174,7 @@ dist_check_SCRIPTS = \
|
||||
test/functional/update/include-old-bundle/test.bats \
|
||||
test/functional/update/missing-os-core/test.bats \
|
||||
test/functional/update/newest-deleted/test.bats \
|
||||
test/functional/update/skip-verified-fullfiles/test.bats \
|
||||
test/functional/update/status/test.bats \
|
||||
test/functional/update/status-no-server-content/test.bats \
|
||||
test/functional/update/status-no-target-content/test.bats \
|
||||
|
||||
@@ -606,6 +606,7 @@ struct list *create_update_list(struct manifest *current, struct manifest *serve
|
||||
{
|
||||
struct list *output = NULL;
|
||||
struct list *list;
|
||||
char *fullname = NULL;
|
||||
|
||||
update_count = 0;
|
||||
update_skip = 0;
|
||||
@@ -615,6 +616,17 @@ struct list *create_update_list(struct manifest *current, struct manifest *serve
|
||||
file = list->data;
|
||||
list = list->next;
|
||||
|
||||
/* Skip files that aren't updated */
|
||||
fullname = mk_full_filename(path_prefix, file->filename);
|
||||
if (fullname == NULL) {
|
||||
abort();
|
||||
}
|
||||
if (verify_file(file, fullname)) {
|
||||
free(fullname);
|
||||
continue;
|
||||
}
|
||||
free(fullname);
|
||||
|
||||
if ((file->last_change > current->version) ||
|
||||
(file->is_rename && file_has_different_hash_in_older_manifest(current, file)) ||
|
||||
!file->is_tracked) {
|
||||
|
||||
@@ -0,0 +1 @@
|
||||
foo
|
||||
@@ -0,0 +1,9 @@
|
||||
NAME="Clear Linux Software for Intel Architecture"
|
||||
VERSION=1
|
||||
ID=clear-linux-os
|
||||
VERSION_ID=10
|
||||
PRETTY_NAME="Clear Linux Software for Intel Architecture"
|
||||
ANSI_COLOR="1;35"
|
||||
HOME_URL="https://clearlinux.org"
|
||||
SUPPORT_URL="https://clearlinux.org"
|
||||
BUG_REPORT_URL="https://bugs.clearlinux.org/jira"
|
||||
@@ -0,0 +1,51 @@
|
||||
#!/usr/bin/env bats
|
||||
|
||||
load "../../swupdlib"
|
||||
|
||||
setup() {
|
||||
clean_test_dir
|
||||
tar -C "$DIR/web-dir/10" -cf "$DIR/web-dir/10/Manifest.MoM.tar" Manifest.MoM Manifest.MoM.signed
|
||||
tar -C "$DIR/web-dir/10" -cf "$DIR/web-dir/10/Manifest.os-core.tar" Manifest.os-core Manifest.os-core.signed
|
||||
tar -C "$DIR/web-dir/10" -cf "$DIR/web-dir/10/Manifest.test-bundle.tar" Manifest.test-bundle Manifest.test-bundle.signed
|
||||
tar -C "$DIR/web-dir/100" -cf "$DIR/web-dir/100/Manifest.MoM.tar" Manifest.MoM Manifest.MoM.signed
|
||||
tar -C "$DIR/web-dir/100" -cf "$DIR/web-dir/100/Manifest.test-bundle.tar" Manifest.test-bundle Manifest.test-bundle.signed
|
||||
sudo chown root:root "$DIR/target-dir/foo"
|
||||
}
|
||||
|
||||
teardown() {
|
||||
pushd "$DIR/web-dir/10"
|
||||
rm *.tar
|
||||
popd
|
||||
pushd "$DIR/web-dir/100"
|
||||
rm *.tar
|
||||
popd
|
||||
sudo chown $(ls -l "$DIR/test.bats" | awk '{ print $3 ":" $4 }') "$DIR/target-dir/foo"
|
||||
}
|
||||
|
||||
@test "update fullfile download skipped when hash verifies correctly" {
|
||||
run sudo sh -c "$SWUPD update $SWUPD_OPTS"
|
||||
|
||||
echo "$output"
|
||||
[ "${lines[2]}" = "Attempting to download version string to memory" ]
|
||||
[ "${lines[3]}" = "Update started." ]
|
||||
[ "${lines[4]}" = "Querying server version." ]
|
||||
[ "${lines[5]}" = "Attempting to download version string to memory" ]
|
||||
[ "${lines[6]}" = "Preparing to update from 10 to 100" ]
|
||||
[ "${lines[7]}" = "Querying current manifest." ]
|
||||
[ "${lines[8]}" = "Querying server manifest." ]
|
||||
[ "${lines[9]}" = "Downloading test-bundle pack for version 100" ]
|
||||
[ "${lines[10]}" = "Statistics for going from version 10 to version 100:" ]
|
||||
[ "${lines[11]}" = " changed manifests : 1" ]
|
||||
[ "${lines[12]}" = " new manifests : 0" ]
|
||||
[ "${lines[13]}" = " deleted manifests : 0" ]
|
||||
[ "${lines[14]}" = " changed files : 0" ]
|
||||
[ "${lines[15]}" = " new files : 0" ]
|
||||
[ "${lines[16]}" = " deleted files : 0" ]
|
||||
[ "${lines[17]}" = "Starting download of remaining update content. This may take a while..." ]
|
||||
[ "${lines[18]}" = "Finishing download of update content..." ]
|
||||
[ "${lines[19]}" = "Staging file content" ]
|
||||
[ "${lines[20]}" = "Update was applied." ]
|
||||
[ "${lines[24]}" = "Update successful. System updated from version 10 to version 100" ]
|
||||
}
|
||||
|
||||
# vi: ft=sh ts=8 sw=2 sts=2 et tw=80
|
||||
@@ -0,0 +1,9 @@
|
||||
MANIFEST 3
|
||||
version: 10
|
||||
previous: 0
|
||||
filecount: 2
|
||||
timestamp: 1451940175
|
||||
contentsize: 13805671819
|
||||
|
||||
M... 9c2d6168821d121bbdfb4279f1ae04216f32ffac6bcad9e7349fc8642f162a93 10 os-core
|
||||
M... e7457826b4c0bef114e29863347ecef2ec819f2a9193d96b1d1e516770974f54 10 test-bundle
|
||||
@@ -0,0 +1,3 @@
|
||||
-----BEGIN PKCS7-----
|
||||
Empty
|
||||
-----END PKCS7-----
|
||||
@@ -0,0 +1,8 @@
|
||||
MANIFEST 3
|
||||
version: 10
|
||||
previous: 0
|
||||
filecount: 1
|
||||
timestamp: 1451936779
|
||||
contentsize: 17929151
|
||||
|
||||
D... cde33514c151abb2b01448be290ab1d5212952571d15e3533cadc15ff82f2cd5 10 /usr
|
||||
@@ -0,0 +1,3 @@
|
||||
-----BEGIN PKCS7-----
|
||||
Empty
|
||||
-----END PKCS7-----
|
||||
@@ -0,0 +1,8 @@
|
||||
MANIFEST 3
|
||||
version: 10
|
||||
previous: 0
|
||||
filecount: 2
|
||||
timestamp: 1451936779
|
||||
contentsize: 17929151
|
||||
|
||||
F... 520f83440d3dddc25ad09ca858b9c669245f82d3181a45cdfe793aac9dd1fb15 10 /foo
|
||||
@@ -0,0 +1,3 @@
|
||||
-----BEGIN PKCS7-----
|
||||
Empty
|
||||
-----END PKCS7-----
|
||||
@@ -0,0 +1,9 @@
|
||||
MANIFEST 3
|
||||
version: 100
|
||||
previous: 0
|
||||
filecount: 2
|
||||
timestamp: 1451940175
|
||||
contentsize: 13805671819
|
||||
|
||||
M... 9c2d6168821d121bbdfb4279f1ae04216f32ffac6bcad9e7349fc8642f162a93 10 os-core
|
||||
M... 845ca4923f95159e424a5c6982088bae758f7735a8494f284bab24cb715ecfe3 100 test-bundle
|
||||
@@ -0,0 +1,3 @@
|
||||
-----BEGIN PKCS7-----
|
||||
Empty
|
||||
-----END PKCS7-----
|
||||
@@ -0,0 +1,8 @@
|
||||
MANIFEST 3
|
||||
version: 100
|
||||
previous: 0
|
||||
filecount: 2
|
||||
timestamp: 1451936779
|
||||
contentsize: 17929151
|
||||
|
||||
F... 520f83440d3dddc25ad09ca858b9c669245f82d3181a45cdfe793aac9dd1fb15 100 /foo
|
||||
@@ -0,0 +1,3 @@
|
||||
-----BEGIN PKCS7-----
|
||||
Empty
|
||||
-----END PKCS7-----
|
||||
Reference in New Issue
Block a user