From c2990fc2b75a5c71dfd6fccdb2d592a5104b3bf5 Mon Sep 17 00:00:00 2001 From: Tudor Marcu Date: Thu, 25 May 2017 12:11:21 -0700 Subject: [PATCH] Hardlink rpms when calling add-rpms To save time on copying fullfiles, just make a hardlink from the files in RPMDIR to the REPODIR. Signed-off-by: Tudor Marcu --- src/builder/builder.go | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) diff --git a/src/builder/builder.go b/src/builder/builder.go index 2e29faf..ea0b050 100644 --- a/src/builder/builder.go +++ b/src/builder/builder.go @@ -498,8 +498,18 @@ func (b *Builder) AddRPMList(rpms []os.FileInfo) { fmt.Println("ERROR: RPM is not valid! Please make sure it was built correctly.") os.Exit(1) } else { - fmt.Printf("Copying %s\n", rpm.Name()) - helpers.CopyFile(b.Repodir+"/"+rpm.Name(), b.Rpmdir+"/"+rpm.Name()) + if _, err = os.Stat(b.Repodir + "/" + rpm.Name()); err == nil { + continue + } + } + fmt.Printf("Hardlinking %s to repodir\n", rpm.Name()) + err := os.Link(b.Rpmdir+"/"+rpm.Name(), b.Repodir+"/"+rpm.Name()) + if err != nil { + err = helpers.CopyFile(b.Repodir+"/"+rpm.Name(), b.Rpmdir+"/"+rpm.Name()) + if err != nil { + helpers.PrintError(err) + os.Exit(1) + } } } // Save current dir so we can get back to it