From 70bc5ae9aaabd509d8826a4dcaf7e0eeafe2fb25 Mon Sep 17 00:00:00 2001 From: Icarus Sparry Date: Wed, 31 Jan 2018 11:40:49 -0800 Subject: [PATCH] Add config to linkPeersAndChange Needed for the rename code. Currently the old Manifest does not have the Info field populated in its files, but the rename code wants to know the size of the files to see if it makes sense to use a deleted file as the source of a rename. This means that we will need to call os.Stat on the files, and we need the config to tell us where they are. Signed-off-by: Icarus Sparry --- swupd/create_manifests.go | 2 +- swupd/manifest.go | 4 ++-- swupd/manifest_test.go | 2 +- 3 files changed, 4 insertions(+), 4 deletions(-) diff --git a/swupd/create_manifests.go b/swupd/create_manifests.go index e94629a..be3d237 100644 --- a/swupd/create_manifests.go +++ b/swupd/create_manifests.go @@ -150,7 +150,7 @@ func processBundles(ui UpdateInfo, c config) ([]*Manifest, error) { oldM := getOldManifest(oldMPath) changedIncludes := compareIncludes(bundle, oldM) oldM.sortFilesName() - changedFiles, added, deleted := bundle.linkPeersAndChange(oldM, ui.minVersion) + changedFiles, added, deleted := bundle.linkPeersAndChange(oldM, c, ui.minVersion) // if nothing changed, skip if changedFiles == 0 && added == 0 && deleted == 0 && !changedIncludes { continue diff --git a/swupd/manifest.go b/swupd/manifest.go index 52d425c..439be40 100644 --- a/swupd/manifest.go +++ b/swupd/manifest.go @@ -374,7 +374,7 @@ func (m *Manifest) sortFilesVersionName() { // in the chroot for that manifest. Link delta peers with the oldManifest // if the file in the oldManifest is not deleted or ghosted. // Expects m and oldManifest files lists to be sorted by name only -func (m *Manifest) linkPeersAndChange(oldManifest *Manifest, minVersion uint32) (int, int, int) { +func (m *Manifest) linkPeersAndChange(oldManifest *Manifest, c config, minVersion uint32) (int, int, int) { // set previous version to oldManifest version m.Header.Previous = oldManifest.Header.Version @@ -854,7 +854,7 @@ func writeIndexManifest(c *config, ui *UpdateInfo, bundles []*Manifest) (string, oldM := getOldManifest(oldMPath) oldM.sortFilesName() // linkPeersAndChange will update file versions correctly - _, _, _ = idxMan.linkPeersAndChange(oldM, ui.minVersion) + _, _, _ = idxMan.linkPeersAndChange(oldM, *c, ui.minVersion) // now add any new files to the full manifest lenIdxM := len(idxMan.Files) lenFullM := len(newFull.Files) diff --git a/swupd/manifest_test.go b/swupd/manifest_test.go index 5f93e1b..135cd0b 100644 --- a/swupd/manifest_test.go +++ b/swupd/manifest_test.go @@ -402,7 +402,7 @@ func TestLinkPeersAndChange(t *testing.T) { // by name. mNew.sortFilesName() mOld.sortFilesName() - changed, added, deleted := mNew.linkPeersAndChange(&mOld, 0) + changed, added, deleted := mNew.linkPeersAndChange(&mOld, config{}, 0) if changed != 2 { t.Errorf("%v files detected as changed when 2 was expected", changed) }