Compare commits
No commits in common. "1b84160dcfc0c21290cca4b3ae774a668e7a49c8" and "f70914aa38a639c476707db60743cb51a4e04b22" have entirely different histories.
1b84160dcf
...
f70914aa38
|
@ -325,15 +325,12 @@ func (p *packer) packFile(path string, fileToPack FileToPack) {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
var data []byte
|
data, err := unix.Mmap(int(f.Fd()), 0, int(fi.Size()),
|
||||||
if fi.Size() > 0 {
|
|
||||||
data, err = unix.Mmap(int(f.Fd()), 0, int(fi.Size()),
|
|
||||||
unix.PROT_READ, unix.MAP_SHARED)
|
unix.PROT_READ, unix.MAP_SHARED)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
p.Abort(fmt.Errorf("mmap %s: %v", fileToPack.Filename, err))
|
p.Abort(fmt.Errorf("mmap %s: %v", fileToPack.Filename, err))
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
// prepare initial directory entry
|
// prepare initial directory entry
|
||||||
info := &packed.File{
|
info := &packed.File{
|
||||||
|
|
|
@ -3,7 +3,6 @@ package main
|
||||||
import (
|
import (
|
||||||
"errors"
|
"errors"
|
||||||
"fmt"
|
"fmt"
|
||||||
"io"
|
|
||||||
"io/ioutil"
|
"io/ioutil"
|
||||||
"net/http"
|
"net/http"
|
||||||
"os"
|
"os"
|
||||||
|
@ -126,22 +125,13 @@ func filesFromListR(prefix, arg string, ftp packer.FilesToPack) error {
|
||||||
|
|
||||||
case fi.Mode().IsRegular():
|
case fi.Mode().IsRegular():
|
||||||
// sniff content type
|
// sniff content type
|
||||||
var ctype string
|
|
||||||
buf := make([]byte, 512)
|
buf := make([]byte, 512)
|
||||||
n, err := f.Read(buf)
|
n, err := f.Read(buf)
|
||||||
switch err {
|
if err != nil {
|
||||||
case nil:
|
return err
|
||||||
buf = buf[:n]
|
|
||||||
ctype = http.DetectContentType(buf)
|
|
||||||
|
|
||||||
case io.EOF:
|
|
||||||
// Empty file; this is typically due to things like
|
|
||||||
// npm webpack producing empty .css files.
|
|
||||||
ctype = "text/plain; charset=UTF-8"
|
|
||||||
|
|
||||||
default:
|
|
||||||
return fmt.Errorf("failed to read %s: %v", arg, err)
|
|
||||||
}
|
}
|
||||||
|
buf = buf[:n]
|
||||||
|
ctype := http.DetectContentType(buf)
|
||||||
|
|
||||||
// augmented rules for JS / CSS / etc.
|
// augmented rules for JS / CSS / etc.
|
||||||
switch {
|
switch {
|
||||||
|
|
Loading…
Reference in New Issue