mirror of
https://github.com/clearlinux/swupd-server.git
synced 2026-08-19 04:57:43 +00:00
Also clean renamed-to files by unsetting the rename bit
Signed-off-by: Matthew Johnson <matthew.johnson@intel.com>
This commit is contained in:
+9
-5
@@ -1037,12 +1037,16 @@ void clean_renames(struct manifest *manifest)
|
||||
list = g_list_first(manifest->files);
|
||||
while (list) {
|
||||
file = list->data;
|
||||
/* if the file is marked as deleted and renamed it is a
|
||||
* renamed-from file. If the rename_peer field is still NULL
|
||||
* then it has been orphaned. Mark these as deleted */
|
||||
if (file->is_deleted && file->is_rename && !file->rename_peer) {
|
||||
hash_set_zeros(file->hash);
|
||||
/* if a file is marked as a rename but has lost its rename_peer
|
||||
* it needs to be cleaned up */
|
||||
if (file->is_rename && !file->rename_peer) {
|
||||
/* no longer a rename */
|
||||
file->is_rename = 0;
|
||||
/* if the file is marked as deleted and renamed it is a
|
||||
* renamed-from file. Mark these as deleted now */
|
||||
if (file->is_deleted) {
|
||||
hash_set_zeros(file->hash);
|
||||
}
|
||||
}
|
||||
|
||||
list = g_list_next(list);
|
||||
|
||||
@@ -34,15 +34,19 @@ setup() {
|
||||
# /usr/lib/bar and /one will be renamed to /usr/lib/baz and /two
|
||||
gen_file_plain_with_content 10 test-bundle /usr/lib/bar "$(seq 100)"
|
||||
gen_file_plain_with_content 10 test-bundle /one "$(printf 'a%.0s' {1..200})"
|
||||
gen_file_plain_with_content 10 test-bundle /usr/lib/kernel/a "$(printf 'a%.0s' {1..210})"
|
||||
|
||||
gen_file_plain_with_content 20 test-bundle /usr/lib/baz "$(seq 100)"
|
||||
gen_file_plain_with_content 20 test-bundle /two "$(printf 'a%.0s' {1..200})"
|
||||
gen_file_plain_with_content 20 test-bundle /usr/lib/kernel/ab "$(printf 'a%.0s' {1..210})"
|
||||
|
||||
# different content just to make sure this works with delta renames as well as
|
||||
# direct renames
|
||||
gen_file_plain_with_content 30 test-bundle /usr/lib/foo "$(seq 100) new"
|
||||
gen_file_plain_with_content 30 test-bundle /usr/lib/kernel/abc "$(printf 'a%.0s' {1..210})"
|
||||
|
||||
gen_file_plain_with_content 40 test-bundle /usr/lib/foo "$(seq 100) new"
|
||||
gen_file_plain_with_content 40 test-bundle /usr/lib/kernel/abc "$(printf 'a%.0s' {1..210})"
|
||||
# new file to force manifest generation
|
||||
gen_file_plain_with_content 40 test-bundle /a "testfile"
|
||||
}
|
||||
@@ -68,11 +72,14 @@ setup() {
|
||||
# version 10: add files to 10
|
||||
[ 1 -eq $(grep $'F\.\.\.\t.*\t10\t/usr/lib/bar' $DIR/www/10/Manifest.test-bundle | wc -l) ]
|
||||
[ 1 -eq $(grep $'F\.\.\.\t.*\t10\t/one' $DIR/www/10/Manifest.test-bundle | wc -l) ]
|
||||
[ 1 -eq $(grep $'F\.b\.\t.*\t10\t/usr/lib/kernel/a' $DIR/www/10/Manifest.test-bundle | wc -l) ]
|
||||
# version 20: rename bar to baz and one to two
|
||||
[ 1 -eq $(grep $'\.d\.r\t.*\t20\t/one' $DIR/www/20/Manifest.test-bundle | wc -l) ]
|
||||
[ 1 -eq $(grep $'F\.\.r\t.*\t20\t/two' $DIR/www/20/Manifest.test-bundle | wc -l) ]
|
||||
[ 1 -eq $(grep $'\.d\.r\t.*\t20\t/usr/lib/bar' $DIR/www/20/Manifest.test-bundle | wc -l) ]
|
||||
[ 1 -eq $(grep $'F\.\.r\t.*\t20\t/usr/lib/baz' $DIR/www/20/Manifest.test-bundle | wc -l) ]
|
||||
[ 1 -eq $(grep $'\.gbr\t.*\t20\t/usr/lib/kernel/a' $DIR/www/20/Manifest.test-bundle | wc -l) ]
|
||||
[ 1 -eq $(grep $'F\.br\t.*\t20\t/usr/lib/kernel/ab' $DIR/www/20/Manifest.test-bundle | wc -l) ]
|
||||
# version 30: original renamed-from file (bar) is now orphaned and therefore
|
||||
# deleted, baz is now a renamed-from file and foo is a renamed-to file.
|
||||
# /two was deleted in this version, so both /one and /two should be marked as
|
||||
@@ -82,6 +89,8 @@ setup() {
|
||||
[ 1 -eq $(grep $'\.d\.\.\t0\{64\}\t20\t/usr/lib/bar' $DIR/www/30/Manifest.test-bundle | wc -l) ]
|
||||
[ 1 -eq $(grep $'\.d\.r\t.*\t30\t/usr/lib/baz' $DIR/www/30/Manifest.test-bundle | wc -l) ]
|
||||
[ 1 -eq $(grep $'F\.\.r\t.*\t30\t/usr/lib/foo' $DIR/www/30/Manifest.test-bundle | wc -l) ]
|
||||
[ 1 -eq $(grep $'\.gbr\t.*\t30\t/usr/lib/kernel/ab' $DIR/www/30/Manifest.test-bundle | wc -l) ]
|
||||
[ 1 -eq $(grep $'F\.br\t.*\t30\t/usr/lib/kernel/abc' $DIR/www/30/Manifest.test-bundle | wc -l) ]
|
||||
|
||||
# version 40: the existing rename from baz -> foo must persist while all
|
||||
# others remain deleted
|
||||
@@ -90,6 +99,7 @@ setup() {
|
||||
[ 1 -eq $(grep $'\.d\.\.\t0\{64\}\t20\t/usr/lib/bar' $DIR/www/40/Manifest.test-bundle | wc -l) ]
|
||||
[ 1 -eq $(grep $'\.d\.r\t.*\t30\t/usr/lib/baz' $DIR/www/40/Manifest.test-bundle | wc -l) ]
|
||||
[ 1 -eq $(grep $'F\.\.r\t.*\t30\t/usr/lib/foo' $DIR/www/40/Manifest.test-bundle | wc -l) ]
|
||||
[ 1 -eq $(grep $'F\.b\.\t.*\t30\t/usr/lib/kernel/abc' $DIR/www/40/Manifest.test-bundle | wc -l) ]
|
||||
}
|
||||
|
||||
# vi: ft=sh ts=8 sw=2 sts=2 et tw=80
|
||||
|
||||
Reference in New Issue
Block a user