automated snapshot
This commit is contained in:
@@ -35,6 +35,7 @@ func NewStorage(snapshotsDir string) (*Storage, error) {
|
||||
snapshotsDir: snapshotsDir,
|
||||
gen: gen,
|
||||
db: db,
|
||||
log: log,
|
||||
}
|
||||
return &s, nil
|
||||
}
|
||||
@@ -84,16 +85,20 @@ func initSchema(db *sql.DB) error {
|
||||
return tx.Commit()
|
||||
}
|
||||
|
||||
func (s *Storage) Save(img *rl.Image) (string, error) {
|
||||
func (s *Storage) Save() (string, error) {
|
||||
id, _ := s.gen.Next()
|
||||
kid := ids.Base62Encode(id)
|
||||
path := filepath.Join(s.snapshotsDir, kid)
|
||||
os.MkdirAll(path, 0755)
|
||||
|
||||
snapshotPng := filepath.Join(path, fmt.Sprintf("%s.png", kid))
|
||||
img := rl.LoadImageFromScreen()
|
||||
defer rl.UnloadImage(img)
|
||||
|
||||
snapshotPng := filepath.Join(path, fmt.Sprintf("%s.png", kid))
|
||||
rl.ExportImage(*img, snapshotPng)
|
||||
|
||||
s.log.Printf("Checking git status...\n")
|
||||
|
||||
hash, branch, committed, err := CommitAllIfDirty(s.repoRoot, "automated snapshot", s.log)
|
||||
|
||||
if err != nil {
|
||||
|
||||
Reference in New Issue
Block a user