diff options
author | kakwa <carpentier.pf@gmail.com> | 2015-11-28 12:11:38 +0100 |
---|---|---|
committer | kakwa <carpentier.pf@gmail.com> | 2015-11-28 12:11:38 +0100 |
commit | f86afb04a2af72c53443e38899ea4c2a87bd581d (patch) | |
tree | d059d93291c07f530775d3130907dafdb64e4b28 | |
parent | aaa3f1b2b9de437386185670bcc135202f1d8099 (diff) | |
download | gitea-f86afb04a2af72c53443e38899ea4c2a87bd581d.tar.gz gitea-f86afb04a2af72c53443e38899ea4c2a87bd581d.zip |
Adding more error handling in dump cmd
The dump cmd did not check the return value of the z.AddFile or
z.AddDir when building the final archive.
It caused the dump command to succeed even if an error occurred.
The resulted dump archive could be corrupted/empty.
(errors could be various: removal by a concurrent process, disk full,
bugs in the dump cmd itself)
-rw-r--r-- | cmd/dump.go | 16 |
1 files changed, 12 insertions, 4 deletions
diff --git a/cmd/dump.go b/cmd/dump.go index 0bf385d065..279099dac8 100644 --- a/cmd/dump.go +++ b/cmd/dump.go @@ -60,10 +60,18 @@ func runDump(ctx *cli.Context) { } workDir, _ := setting.WorkDir() - z.AddFile("gogs-repo.zip", path.Join(workDir, "gogs-repo.zip")) - z.AddFile("gogs-db.sql", path.Join(workDir, "gogs-db.sql")) - z.AddDir("custom", path.Join(workDir, "custom")) - z.AddDir("log", path.Join(workDir, "log")) + if err := z.AddFile("gogs-repo.zip", path.Join(workDir, "gogs-repo.zip")); err !=nil { + log.Fatalf("Fail to include gogs-repo.zip: %v", err) + } + if err := z.AddFile("gogs-db.sql", path.Join(workDir, "gogs-db.sql")); err !=nil { + log.Fatalf("Fail to include gogs-db.sql: %v", err) + } + if err := z.AddDir("custom", path.Join(workDir, "custom")); err !=nil { + log.Fatalf("Fail to include custom: %v", err) + } + if err := z.AddDir("log", path.Join(workDir, "log")); err !=nil { + log.Fatalf("Fail to include log: %v", err) + } // FIXME: SSH key file. if err = z.Close(); err != nil { os.Remove(fileName) |