aboutsummaryrefslogtreecommitdiffstats
path: root/models/wiki.go
diff options
context:
space:
mode:
authorBwko <bouwko@gmail.com>2016-12-01 00:56:15 +0100
committerKim "BKC" Carlbäcker <kim.carlbacker@gmail.com>2016-12-02 07:41:19 +0100
commit4ff0db0246fa8a2add1032220024975203b93d72 (patch)
tree6395dd608ba47cc6429bc12d9595f09ebb915f02 /models/wiki.go
parent5ab85372da74bd95f7143fd59c2c600d4c9894d0 (diff)
downloadgitea-4ff0db0246fa8a2add1032220024975203b93d72.tar.gz
gitea-4ff0db0246fa8a2add1032220024975203b93d72.zip
Catch os... errors
Diffstat (limited to 'models/wiki.go')
-rw-r--r--models/wiki.go16
1 files changed, 13 insertions, 3 deletions
diff --git a/models/wiki.go b/models/wiki.go
index b010baeb52..890e62b0cd 100644
--- a/models/wiki.go
+++ b/models/wiki.go
@@ -112,7 +112,11 @@ func (repo *Repository) updateWikiPage(doer *User, oldTitle, title, content, mes
return ErrWikiAlreadyExist{filename}
}
} else {
- os.Remove(path.Join(localPath, oldTitle+".md"))
+ file := path.Join(localPath, oldTitle+".md")
+
+ if err := os.Remove(file); err != nil {
+ return fmt.Errorf("Fail to remove %s: %v", file, err)
+ }
}
// SECURITY: if new file is a symlink to non-exist critical file,
@@ -120,7 +124,10 @@ func (repo *Repository) updateWikiPage(doer *User, oldTitle, title, content, mes
// as a new page operation.
// So we want to make sure the symlink is removed before write anything.
// The new file we created will be in normal text format.
- os.Remove(filename)
+
+ if err := os.Remove(filename); err != nil {
+ return fmt.Errorf("Fail to remove %s: %v", filename, err)
+ }
if err = ioutil.WriteFile(filename, []byte(content), 0666); err != nil {
return fmt.Errorf("WriteFile: %v", err)
@@ -168,7 +175,10 @@ func (repo *Repository) DeleteWikiPage(doer *User, title string) (err error) {
title = ToWikiPageName(title)
filename := path.Join(localPath, title+".md")
- os.Remove(filename)
+
+ if err := os.Remove(filename); err != nil {
+ return fmt.Errorf("Fail to remove %s: %v", filename, err)
+ }
message := "Delete page '" + title + "'"