accept -tmp

This commit is contained in:
bel
2026-01-02 08:07:34 -07:00
parent 922b4fe5ad
commit b0f79254e0
2 changed files with 16 additions and 4 deletions

View File

@@ -5,7 +5,6 @@ import (
"fmt"
"io"
"io/ioutil"
"gitea.inhome.blapointe.com/local/storage"
"log"
"os"
"os/exec"
@@ -14,6 +13,8 @@ import (
"sort"
"time"
"gitea.inhome.blapointe.com/local/storage"
"github.com/google/uuid"
)
@@ -28,6 +29,7 @@ type Config struct {
StoreUser string
StorePass string
Cmd string
Tmp string
}
type LastN struct {
@@ -63,13 +65,20 @@ func (lastN *LastN) Push() error {
return err
}
archive := path.Join(
os.TempDir(),
lastN.conf.Tmp,
fmt.Sprintf(
"%s.%s.tar",
time.Now().Format("2006.01.02.15.04.05"),
uuid.New().String(),
),
)
defer func() {
err := recover()
os.Remove(archive)
if err != nil {
panic(err)
}
}()
cmd := exec.Command(
"tar",
"-czf",

View File

@@ -2,12 +2,13 @@ package main
import (
"fmt"
"gitea.inhome.blapointe.com/local/args"
"gitea.inhome.blapointe.com/local/lastn/lastn"
"log"
"os"
"path"
"path/filepath"
"gitea.inhome.blapointe.com/local/args"
"gitea.inhome.blapointe.com/local/lastn/lastn"
)
func main() {
@@ -49,6 +50,7 @@ func config() lastn.Config {
as.Append(args.STRING, "ns", "ns for backups", path.Join("lastn", "dev"))
as.Append(args.STRING, "rclone-conf", "path to rclone conf", path.Join(os.Getenv("HOME"), "/.config/rclone/rclone.conf"))
as.Append(args.STRING, "rclone-alias", "rclone backend name", "blapointe-drive-enc")
as.Append(args.STRING, "tmp", "tmp dir", os.TempDir())
if err := as.Parse(); err != nil {
panic(err)
}
@@ -67,5 +69,6 @@ func config() lastn.Config {
StoreUser: as.Get("storeuser").GetString(),
StorePass: as.Get("storepass").GetString(),
Cmd: as.Get("cmd").GetString(),
Tmp: as.GetString("tmp"),
}
}