summaryrefslogtreecommitdiffstats
path: root/cmd/dump.go
diff options
context:
space:
mode:
authorUnknown <joe2010xtmf@163.com>2014-05-05 13:08:01 -0400
committerUnknown <joe2010xtmf@163.com>2014-05-05 13:08:01 -0400
commitc1eb4d894a092aed1b87ddf5f80ee824fd56789d (patch)
treeb58beee7c762cbbb1cec524c16471788820609b6 /cmd/dump.go
parent5f653898f3b39669ce9dbf0ee2263c391695019d (diff)
downloadgitea-c1eb4d894a092aed1b87ddf5f80ee824fd56789d.tar.gz
gitea-c1eb4d894a092aed1b87ddf5f80ee824fd56789d.zip
Clean api code
Diffstat (limited to 'cmd/dump.go')
-rw-r--r--cmd/dump.go13
1 files changed, 8 insertions, 5 deletions
diff --git a/cmd/dump.go b/cmd/dump.go
index 035f7828b8..1bac1aeeb2 100644
--- a/cmd/dump.go
+++ b/cmd/dump.go
@@ -5,9 +5,11 @@
package cmd
import (
+ "fmt"
"log"
"os"
"path"
+ "time"
"github.com/Unknwon/cae/zip"
"github.com/codegangsta/cli"
@@ -43,11 +45,12 @@ func runDump(*cli.Context) {
log.Fatalf("Fail to dump database: %v", err)
}
+ fileName := fmt.Sprintf("gogs-dump-%d.zip", time.Now().Unix())
log.Printf("Packing dump files...")
- z, err := zip.Create("gogs-dump.zip")
+ z, err := zip.Create(fileName)
if err != nil {
- os.Remove("gogs-dump.zip")
- log.Fatalf("Fail to create gogs-dump.zip: %v", err)
+ os.Remove(fileName)
+ log.Fatalf("Fail to create %s: %v", fileName, err)
}
execDir, _ := base.ExecDir()
@@ -56,8 +59,8 @@ func runDump(*cli.Context) {
z.AddFile("custom/conf/app.ini", path.Join(execDir, "custom/conf/app.ini"))
z.AddDir("log", path.Join(execDir, "log"))
if err = z.Close(); err != nil {
- os.Remove("gogs-dump.zip")
- log.Fatalf("Fail to save gogs-dump.zip: %v", err)
+ os.Remove(fileName)
+ log.Fatalf("Fail to save %s: %v", fileName, err)
}
log.Println("Finish dumping!")