From f5b614e39caf050714df5bc519123e1cb9cc378d Mon Sep 17 00:00:00 2001 From: Matthew Johnson Date: Fri, 1 Dec 2017 12:30:31 -0800 Subject: [PATCH] Add comments to pack.c As I was trying to understand the flow of pack.c I added comments as notes to myself. These are helpful enough to be in the source. Signed-off-by: Matthew Johnson --- src/pack.c | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/src/pack.c b/src/pack.c index 0cdbae1..d0f761e 100644 --- a/src/pack.c +++ b/src/pack.c @@ -138,12 +138,13 @@ static void prepare_pack(struct packdata *pack) return; } + /* read in manifest from file */ pack->end_manifest = manifest_from_file(pack->to, pack->module); - + /* wipe any old packs (failed) and re-create pack directory structure */ empty_pack_stage(0, pack->from, pack->to, pack->module); - + /* match up old and new manifests */ match_manifests(manifest, pack->end_manifest); - + /* link renames together */ link_renames(pack->end_manifest->files, pack->to); } @@ -252,6 +253,8 @@ static GList *consolidate_packs_delta_files(GList *files, struct packdata *pack) file = item->data; item = g_list_next(item); + /* skip old files, files without a peer, and files that are not + * files, directories, or links */ if ((file->last_change <= pack->from) || (!file->peer) || (!file->is_file && !file->is_dir && !file->is_link)) { @@ -261,7 +264,10 @@ static GList *consolidate_packs_delta_files(GList *files, struct packdata *pack) 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); + /* check for existence */ ret = stat(from, &stat_delta); + /* only add if delta does not already exist and the file is not + * in files */ if (ret && !find_file_in_list(files, file)) { files = g_list_prepend(files, file); }