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

@@ -61,7 +61,9 @@ func (i ArtifactIndex) CleanPath() ArtifactIndex {
// which will consist in just of an repository.yaml which is just the repository structure with the list of package artifact. // which will consist in just of an repository.yaml which is just the repository structure with the list of package artifact.
// In this way a generic client can fetch the packages and, after unpacking the tree, performing queries to install packages. // In this way a generic client can fetch the packages and, after unpacking the tree, performing queries to install packages.
type PackageArtifact struct { type PackageArtifact struct {
Path string `json:"path"` Path string `json:"path"`
CompressedPath string `json:"compressedpath"`
Dependencies []*PackageArtifact `json:"dependencies"` Dependencies []*PackageArtifact `json:"dependencies"`
CompileSpec *LuetCompilationSpec `json:"compilationspec"` CompileSpec *LuetCompilationSpec `json:"compilationspec"`
Checksums Checksums `json:"checksums"` Checksums Checksums `json:"checksums"`
@@ -223,7 +225,8 @@ func (a *PackageArtifact) Compress(src string, concurrency int) error {
} }
w.Close() w.Close()
os.RemoveAll(a.Path) // Remove original os.RemoveAll(a.Path) // Remove original
a.Path = gzipfile a.CompressedPath = gzipfile
//a.Path = gzipfile
} }
return errors.New("Compression type must be supplied") return errors.New("Compression type must be supplied")
} }
@@ -236,13 +239,13 @@ func (a *PackageArtifact) Unpack(dst string, keepPerms bool) error {
case GZip: case GZip:
// Create the uncompressed archive // Create the uncompressed archive
archive, err := os.Create(a.GetPath() + ".tar") archive, err := os.Create(a.GetPath())
if err != nil { if err != nil {
return err 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 { if err != nil {
return err return err
} }
@@ -260,7 +263,7 @@ func (a *PackageArtifact) Unpack(dst string, keepPerms bool) error {
return err return err
} }
err = helpers.Untar(a.GetPath()+".tar", dst, keepPerms) err = helpers.Untar(a.GetPath(), dst, keepPerms)
if err != nil { if err != nil {
return err return err
} }