mirror of
https://github.com/EnumeratedDev/bpm.git
synced 2026-09-21 04:56:12 +00:00
Add package installation and last update dates
This commit is contained in:
+27
-2
@@ -16,13 +16,15 @@ import (
|
||||
"strconv"
|
||||
"strings"
|
||||
"syscall"
|
||||
"time"
|
||||
|
||||
"gopkg.in/yaml.v3"
|
||||
)
|
||||
|
||||
type BPMPackage struct {
|
||||
PkgInfo *PackageInfo
|
||||
PkgFiles []*PackageFileEntry
|
||||
PkgInfo *PackageInfo
|
||||
PkgFiles []*PackageFileEntry
|
||||
LocalInfo PackageLocalInfo
|
||||
}
|
||||
|
||||
type PackageInfo struct {
|
||||
@@ -75,6 +77,11 @@ type PackageFileEntry struct {
|
||||
SizeInBytes int64
|
||||
}
|
||||
|
||||
type PackageLocalInfo struct {
|
||||
InstalledOn int64 `yaml:"installed_on"`
|
||||
LastUpdatedOn int64 `yaml:"last_updated_on"`
|
||||
}
|
||||
|
||||
func (pkg *BPMPackage) GetInstalledSize() int64 {
|
||||
var totalSize int64 = 0
|
||||
for _, entry := range pkg.PkgFiles {
|
||||
@@ -979,6 +986,24 @@ func installPackage(filename, rootDir string, verbose, force bool) error {
|
||||
return err
|
||||
}
|
||||
|
||||
// Write local package information
|
||||
localInfo := getPackageLocalInfo(bpmpkg.PkgInfo.Name, rootDir)
|
||||
if !packageInstalled {
|
||||
localInfo.InstalledOn = time.Now().Unix()
|
||||
}
|
||||
localInfo.LastUpdatedOn = time.Now().Unix()
|
||||
|
||||
localFile, err := os.OpenFile(path.Join(pkgDir, "local"), os.O_WRONLY|os.O_CREATE, 0644)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
defer localFile.Close()
|
||||
|
||||
err = yaml.NewEncoder(localFile).Encode(localInfo)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
// Save remove package scripts
|
||||
packageScripts, err := ReadPackageScripts(filename)
|
||||
if err != nil {
|
||||
|
||||
Reference in New Issue
Block a user