localdisk: fix TODO which resulted in a race/crash.

Change-Id: I7ff0be046c07e5fd33c861afd10b5e725066a033
This commit is contained in:
Brad Fitzpatrick 2012-04-22 18:51:41 -07:00
parent 1d3703f7ef
commit 7b6a26ffeb
1 changed files with 7 additions and 3 deletions
pkg/blobserver/localdisk

View File

@ -131,7 +131,11 @@ func (ds *DiskStorage) ReceiveBlob(blobRef *blobref.BlobRef, source io.Reader) (
}
func linkAlreadyExists(err error) bool {
le, ok := err.(*os.LinkError)
// TODO(bradfitz): GO1 not tested; is this ErrExist or syscall.EEXIST?
return ok && le.Op == "link" && le.Err == os.ErrExist
if os.IsExist(err) {
return true
}
if le, ok := err.(*os.LinkError); ok && os.IsExist(le.Err) {
return true
}
return false
}