// wrapErr wraps s.err to a filestore-specific error, if possible func (s *errStore) wrapErr(err error) error { if os.IsNotExist(err) { if pathError, ok := err.(*os.PathError); ok { return store.NewPathNotFoundError("path not found: " + pathError.Path) } return store.NewPathNotFoundError(fmt.Sprintf("path not found: %s", err)) } return err }
func (i *pathIO) assertPathInsideContentRoot(p gopath.GoPath) { if i.hasErr() { return } if !i.isPathInsideContentRoot(p) { i.setErr(store.NewPathNotFoundError( fmt.Sprintf("%s is not inside content root %s", p, i.contentRoot), )) } }
func (s *errStore) prependErr(prefix string) { if s.err != nil { var msg = fmt.Sprintf("%s: %s", prefix, s.err.Error()) switch { case store.IsPathNotFoundError(s.err): s.err = store.NewPathNotFoundError(msg) case store.IsAccessDeniedError(s.err): s.err = store.NewAccessDeniedError(msg) default: s.err = fmt.Errorf(msg) } } }
func (i *pathIO) assertFileIsNotHidden(p gopath.GoPath) { if i.hasErr() { return } if p.HasErr() { i.syncedErrs(p) return } if strings.HasPrefix(p.Base(), ".") { i.setErr(store.NewPathNotFoundError(fmt.Sprintf("%s is a hidden file and may not be displayed", p))) } // HINT: recursive call, ending at content root if i.isPathInsideContentRoot(p) { i.assertFileIsNotHidden(p.ToSlash().Dir()) } }
func (s *MockStore) FileSizeForRequest(request *http.Request) int64 { if !s.exists { s.err = store.NewPathNotFoundError("mocked PathNotFoundError") } return 0 }
func (s *MockStore) Delete(request *http.Request) { if !s.exists { s.err = store.NewPathNotFoundError("mocked PathNotFoundError") } }
func (s *MockStore) ReadString(request *http.Request) string { if !s.exists { s.err = store.NewPathNotFoundError("mocked PathNotFoundError") } return "" }
func (s *MockStore) OpenReader(request *http.Request) io.ReadCloser { if !s.exists { s.err = store.NewPathNotFoundError("mocked PathNotFoundError") } return nil }
func (s *MockStore) MimeTypeForRequest(request *http.Request) string { if !s.exists { s.err = store.NewPathNotFoundError("mocked PathNotFoundError") } return s.mimeType }
func (s *MockStore) ModTimeForRequest(request *http.Request) time.Time { if !s.exists { s.err = store.NewPathNotFoundError("mocked PathNotFoundError") } return time.Now() }