diff --git a/include/swupd.h b/include/swupd.h index 75bc80c..43a5002 100644 --- a/include/swupd.h +++ b/include/swupd.h @@ -244,7 +244,7 @@ extern void type_change_detection(struct manifest *manifest); extern void rename_detection(struct manifest *manifest, int last_change, GList *last_versions_list); extern void link_renames(GList *newfiles, struct manifest *from_manifest); -extern void __create_delta(struct file *file, int from_version); +extern void __create_delta(struct file *file, int from_version, char *from_hash); extern void account_delta_hit(void); extern void account_delta_miss(void); diff --git a/src/delta.c b/src/delta.c index 3ddb13a..4b72546 100644 --- a/src/delta.c +++ b/src/delta.c @@ -35,9 +35,9 @@ #include "swupd.h" #include "xattrs.h" -void __create_delta(struct file *file, int from_version) +void __create_delta(struct file *file, int from_version, char *from_hash) { - char *original, *newfile, *outfile, *dotfile, *testnewfile; + char *original, *newfile, *outfile, *dotfile, *testnewfile, *sanitycheck; char *conf, *param1, *param2; int ret; @@ -62,9 +62,10 @@ void __create_delta(struct file *file, int from_version) conf = config_output_dir(); - string_or_die(&outfile, "%s/%i/delta/%i-%i-%s", conf, file->last_change, from_version, file->last_change, file->hash); - string_or_die(&dotfile, "%s/%i/delta/.%i-%i-%s", conf, file->last_change, from_version, file->last_change, file->hash); - string_or_die(&testnewfile, "%s/%i/delta/.%i-%i-%s.testnewfile", conf, file->last_change, from_version, file->last_change, file->hash); + string_or_die(&outfile, "%s/%i/delta/%i-%i-%s-%s", conf, file->last_change, from_version, file->last_change, from_hash, file->hash); + string_or_die(&dotfile, "%s/%i/delta/.%i-%i-%s-%s", conf, file->last_change, from_version, file->last_change, from_hash, file->hash); + string_or_die(&testnewfile, "%s/%i/delta/.%i-%i-%s-%s.testnewfile", conf, file->last_change, from_version, file->last_change, from_hash, file->hash); + string_or_die(&sanitycheck, "cmp -s \"%s\" \"%s\"", newfile, testnewfile); LOG(file, "Making delta", "%s->%s", original, newfile); @@ -111,7 +112,6 @@ void __create_delta(struct file *file, int from_version) string_or_die(¶m1, "%s", newfile); string_or_die(¶m2, "%s", testnewfile); - char *const sanitycheck[] = { "cmp", "-s", param1, param2, NULL }; ret = system_argv(sanitycheck); free(param1); free(param2); diff --git a/src/pack.c b/src/pack.c index b34ea56..a1fbc51 100644 --- a/src/pack.c +++ b/src/pack.c @@ -254,8 +254,8 @@ static GList *consolidate_packs_delta_files(GList *files, struct packdata *pack) continue; } - string_or_die(&from, "%s/%i/delta/%i-%i-%s", staging_dir, file->last_change, - file->peer->last_change, file->last_change, file->hash); + string_or_die(&from, "%s/%i/delta/%i-%i-%s-%s", staging_dir, file->last_change, + file->peer->last_change, file->last_change, file->peer->hash, file->hash); ret = stat(from, &stat_delta); if (ret && !find_file_in_list(files, file)) { @@ -274,7 +274,7 @@ static void create_delta(gpointer data, __unused__ gpointer user_data) /* if the file was not found in the from version, skip delta creation */ if (file->peer) { - __create_delta(file, file->peer->last_change); + __create_delta(file, file->peer->last_change, file->peer->hash); } } @@ -353,11 +353,11 @@ static int make_final_pack(struct packdata *pack) /* for each file changed since */ /* locate delta, check if the diff it's from is >= */ - string_or_die(&from, "%s/%i/delta/%i-%i-%s", staging_dir, file->last_change, - file->peer->last_change, file->last_change, file->hash); - string_or_die(&to, "%s/%s/%i_to_%i/delta/%i-%i-%s", packstage_dir, + string_or_die(&from, "%s/%i/delta/%i-%i-%s-%s", staging_dir, file->last_change, + file->peer->last_change, file->last_change, file->peer->hash, file->hash); + string_or_die(&to, "%s/%s/%i_to_%i/delta/%i-%i-%s-%s", packstage_dir, pack->module, pack->from, pack->to, file->peer->last_change, - file->last_change, file->hash); + file->last_change, file->peer->hash, file->hash); string_or_die(&tarfrom, "%s/%i/files/%s.tar", staging_dir, file->last_change, file->hash); string_or_die(&tarto, "%s/%s/%i_to_%i/staged/%s.tar", packstage_dir,