summaryrefslogtreecommitdiffstats
path: root/models/ssh_key.go
diff options
context:
space:
mode:
Diffstat (limited to 'models/ssh_key.go')
-rw-r--r--models/ssh_key.go7
1 files changed, 6 insertions, 1 deletions
diff --git a/models/ssh_key.go b/models/ssh_key.go
index 53a31f6f8d..f98a6b76f4 100644
--- a/models/ssh_key.go
+++ b/models/ssh_key.go
@@ -373,7 +373,12 @@ func addKey(e Engine, key *PublicKey) (err error) {
// Calculate fingerprint.
tmpPath := strings.Replace(path.Join(os.TempDir(), fmt.Sprintf("%d", time.Now().Nanosecond()),
"id_rsa.pub"), "\\", "/", -1)
- os.MkdirAll(path.Dir(tmpPath), os.ModePerm)
+ dir := path.Dir(tmpPath)
+
+ if err := os.MkdirAll(dir, os.ModePerm); err != nil {
+ return fmt.Errorf("Fail to create dir %s: %v", dir, err)
+ }
+
if err = ioutil.WriteFile(tmpPath, []byte(key.Content), 0644); err != nil {
return err
}