Use a separate attribute to handle the compressed artifact

Refers to #33
This commit is contained in:
Ettore Di Giacinto
2019-12-30 14:46:17 +01:00
parent 5155681513
commit a40ecaea40

View File

@@ -62,6 +62,8 @@ func (i ArtifactIndex) CleanPath() ArtifactIndex {
// In this way a generic client can fetch the packages and, after unpacking the tree, performing queries to install packages.
type PackageArtifact struct {
Path string `json:"path"`
CompressedPath string `json:"compressedpath"`
Dependencies []*PackageArtifact `json:"dependencies"`
CompileSpec *LuetCompilationSpec `json:"compilationspec"`
Checksums Checksums `json:"checksums"`
@@ -223,7 +225,8 @@ func (a *PackageArtifact) Compress(src string, concurrency int) error {
}
w.Close()
os.RemoveAll(a.Path) // Remove original
a.Path = gzipfile
a.CompressedPath = gzipfile
//a.Path = gzipfile
}
return errors.New("Compression type must be supplied")
}
@@ -236,13 +239,13 @@ func (a *PackageArtifact) Unpack(dst string, keepPerms bool) error {
case GZip:
// Create the uncompressed archive
archive, err := os.Create(a.GetPath() + ".tar")
archive, err := os.Create(a.GetPath())
if err != nil {
return err
}
defer os.RemoveAll(a.GetPath() + ".tar")
defer os.RemoveAll(a.GetPath())
original, err := os.Open(a.Path)
original, err := os.Open(a.CompressedPath)
if err != nil {
return err
}
@@ -260,7 +263,7 @@ func (a *PackageArtifact) Unpack(dst string, keepPerms bool) error {
return err
}
err = helpers.Untar(a.GetPath()+".tar", dst, keepPerms)
err = helpers.Untar(a.GetPath(), dst, keepPerms)
if err != nil {
return err
}