Handle a couple errors around link files

This commit is contained in:
rubyist 2014-09-22 14:19:50 -04:00
parent 1be35b21b6
commit 567907c2d4
2 changed files with 8 additions and 1 deletions

@ -50,6 +50,9 @@ func LocalMediaPath(sha string) (string, error) {
}
func LocalLinkPath(sha string) (string, error) {
if len(sha) == 0 {
return "", fmt.Errorf("Error trying to create local object directory, invalid sha: '%s'", sha)
}
path := filepath.Join(LocalLinkDir, sha[0:2])
if err := os.MkdirAll(path, 0744); err != nil {
return "", fmt.Errorf("Error trying to create local object directory in '%s': %s", path, err)

@ -64,7 +64,11 @@ func (p *Pointer) CreateLink(filename string) error {
return err
}
gitHash.Write([]byte(p.Encoded()))
_, err = gitHash.Write([]byte(p.Encoded()))
if err != nil {
return err
}
gitHash.Close()
hash := gitHash.Hash()