Compare commits

...

2 Commits

Author SHA1 Message Date
Audrius Butkevicius
c294d5f087 Fix crash on walker error (fixes #1507) 2015-03-22 14:09:14 +00:00
Jakob Borg
10ead2e61f Send correct MIME type for SVG images (fixes #1506) 2015-03-22 12:56:50 +01:00
3 changed files with 12 additions and 1 deletions

View File

@@ -828,6 +828,8 @@ func mimeTypeForFile(file string) string {
return "application/x-font-ttf"
case ".woff":
return "application/x-font-woff"
case ".svg":
return "image/svg+xml"
default:
return mime.TypeByExtension(ext)
}

View File

@@ -111,7 +111,8 @@ func (w *Walker) walkAndHashFiles(fchan chan protocol.FileInfo) filepath.WalkFun
// Return value used when we are returning early and don't want to
// process the item. For directories, this means do-not-descend.
var skip error // nil
if info.IsDir() {
// info nil when error is not nil
if info != nil && info.IsDir() {
skip = filepath.SkipDir
}

View File

@@ -259,6 +259,14 @@ func TestNormalization(t *testing.T) {
}
}
func TestIssue1507(t *testing.T) {
w := Walker{}
c := make(chan protocol.FileInfo, 100)
fn := w.walkAndHashFiles(c)
fn("", nil, protocol.ErrClosed)
}
func walkDir(dir string) ([]protocol.FileInfo, error) {
w := Walker{
Dir: dir,