mirror of https://github.com/perkeep/perkeep.git
Merge branch 'master' of ssh://camlistore.org:29418/camlistore
This commit is contained in:
commit
059b21f4d2
|
@ -299,7 +299,7 @@ func (x *Index) GetOwnerClaims(permaNode, owner *blobref.BlobRef) (cl search.Cla
|
|||
return
|
||||
}
|
||||
|
||||
func (x *Index) GetBlobMimeType(blob *blobref.BlobRef) (mime string, size int64, err error) {
|
||||
func (x *Index) GetBlobMIMEType(blob *blobref.BlobRef) (mime string, size int64, err error) {
|
||||
key := "meta:" + blob.String()
|
||||
meta, err := x.s.Get(key)
|
||||
if err == ErrNotFound {
|
||||
|
@ -561,7 +561,7 @@ func (x *Index) GetFileInfo(fileRef *blobref.BlobRef) (*search.FileInfo, error)
|
|||
fi := &search.FileInfo{
|
||||
Size: size,
|
||||
FileName: urld(valPart[1]),
|
||||
MimeType: urld(valPart[2]),
|
||||
MIMEType: urld(valPart[2]),
|
||||
}
|
||||
return fi, nil
|
||||
}
|
||||
|
|
|
@ -418,22 +418,22 @@ func Index(t *testing.T, initIdx func() *index.Index) {
|
|||
}
|
||||
}
|
||||
|
||||
// GetBlobMimeType
|
||||
// GetBlobMIMEType
|
||||
{
|
||||
mime, size, err := id.Index.GetBlobMimeType(pn)
|
||||
mime, size, err := id.Index.GetBlobMIMEType(pn)
|
||||
if err != nil {
|
||||
t.Errorf("GetBlobMimeType(%q) = %v", pn, err)
|
||||
t.Errorf("GetBlobMIMEType(%q) = %v", pn, err)
|
||||
} else {
|
||||
if e := "application/json; camliType=permanode"; mime != e {
|
||||
t.Errorf("GetBlobMimeType(%q) mime = %q, want %q", pn, mime, e)
|
||||
t.Errorf("GetBlobMIMEType(%q) mime = %q, want %q", pn, mime, e)
|
||||
}
|
||||
if size == 0 {
|
||||
t.Errorf("GetBlobMimeType(%q) size is zero", pn)
|
||||
t.Errorf("GetBlobMIMEType(%q) size is zero", pn)
|
||||
}
|
||||
}
|
||||
_, _, err = id.Index.GetBlobMimeType(blobref.Parse("abc-123"))
|
||||
_, _, err = id.Index.GetBlobMIMEType(blobref.Parse("abc-123"))
|
||||
if err != os.ErrNotExist {
|
||||
t.Errorf("GetBlobMimeType(dummy blobref) = %v; want os.ErrNotExist", err)
|
||||
t.Errorf("GetBlobMIMEType(dummy blobref) = %v; want os.ErrNotExist", err)
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -581,8 +581,8 @@ func Files(t *testing.T, initIdx func() *index.Index) {
|
|||
if g, e := fi.FileName, "foo.html"; g != e {
|
||||
t.Errorf("FileName = %q, want %q", g, e)
|
||||
}
|
||||
if g, e := fi.MimeType, "text/html"; g != e {
|
||||
t.Errorf("MimeType = %q, want %q", g, e)
|
||||
if g, e := fi.MIMEType, "text/html"; g != e {
|
||||
t.Errorf("MIMEType = %q, want %q", g, e)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -522,7 +522,7 @@ type DescribedBlob struct {
|
|||
Request *DescribeRequest `json:"-"`
|
||||
|
||||
BlobRef *blobref.BlobRef `json:"blobRef"`
|
||||
MimeType string `json:"mimeType"`
|
||||
MIMEType string `json:"mimeType"`
|
||||
CamliType string `json:"camliType"`
|
||||
Size int64 `json:"size,"`
|
||||
|
||||
|
@ -715,7 +715,7 @@ func (b *DescribedBlob) thumbnail(thumbSize int) (path string, width, height int
|
|||
return image, thumbSize, thumbSize, true
|
||||
}
|
||||
|
||||
// TODO: different thumbnails based on peer.File.MimeType.
|
||||
// TODO: different thumbnails based on peer.File.MIMEType.
|
||||
return "file.png", thumbSize, thumbSize, true
|
||||
}
|
||||
if peer.Dir != nil {
|
||||
|
@ -891,7 +891,7 @@ func (dr *DescribeRequest) addError(br *blobref.BlobRef, err error) {
|
|||
}
|
||||
|
||||
func (dr *DescribeRequest) describeReally(br *blobref.BlobRef, depth int) {
|
||||
mime, size, err := dr.sh.index.GetBlobMimeType(br)
|
||||
mime, size, err := dr.sh.index.GetBlobMIMEType(br)
|
||||
if err == os.ErrNotExist {
|
||||
return
|
||||
}
|
||||
|
@ -904,7 +904,7 @@ func (dr *DescribeRequest) describeReally(br *blobref.BlobRef, depth int) {
|
|||
// DescribedBlob/DescribedPermanode/DescribedFile, not json
|
||||
// maps. Then add JSON marhsallers to those types. Add tests.
|
||||
des := dr.describedBlob(br)
|
||||
des.setMimeType(mime)
|
||||
des.setMIMEType(mime)
|
||||
des.Size = size
|
||||
|
||||
switch des.CamliType {
|
||||
|
@ -1200,8 +1200,8 @@ func (sh *Handler) serveSignerPaths(rw http.ResponseWriter, req *http.Request) {
|
|||
|
||||
const camliTypePrefix = "application/json; camliType="
|
||||
|
||||
func (d *DescribedBlob) setMimeType(mime string) {
|
||||
d.MimeType = mime
|
||||
func (d *DescribedBlob) setMIMEType(mime string) {
|
||||
d.MIMEType = mime
|
||||
if strings.HasPrefix(mime, camliTypePrefix) {
|
||||
d.CamliType = mime[len(camliTypePrefix):]
|
||||
}
|
||||
|
|
|
@ -91,12 +91,12 @@ func (cl ClaimList) String() string {
|
|||
type FileInfo struct {
|
||||
Size int64 `json:"size"`
|
||||
FileName string `json:"fileName"`
|
||||
// MimeType may be set for files, but never for directories.
|
||||
MimeType string `json:"mimeType,omitempty"`
|
||||
// MIMEType may be set for files, but never for directories.
|
||||
MIMEType string `json:"mimeType,omitempty"`
|
||||
}
|
||||
|
||||
func (fi *FileInfo) IsImage() bool {
|
||||
return strings.HasPrefix(fi.MimeType, "image/")
|
||||
return strings.HasPrefix(fi.MIMEType, "image/")
|
||||
}
|
||||
|
||||
type Path struct {
|
||||
|
@ -170,7 +170,7 @@ type Index interface {
|
|||
GetOwnerClaims(permaNode, owner *blobref.BlobRef) (ClaimList, error)
|
||||
|
||||
// os.ErrNotExist should be returned if the blob isn't known
|
||||
GetBlobMimeType(blob *blobref.BlobRef) (mime string, size int64, err error)
|
||||
GetBlobMIMEType(blob *blobref.BlobRef) (mime string, size int64, err error)
|
||||
|
||||
// ExistingFileSchemas returns 0 or more blobrefs of "bytes"
|
||||
// (TODO(bradfitz): or file?) schema blobs that represent the
|
||||
|
|
|
@ -454,7 +454,7 @@ func (pr *publishRequest) serveSubject() {
|
|||
pr.pf("<div>File: %s, %d bytes, type %s</div>",
|
||||
html.EscapeString(des.File.FileName),
|
||||
des.File.Size,
|
||||
des.File.MimeType)
|
||||
des.File.MIMEType)
|
||||
if des.File.IsImage() {
|
||||
pr.pf("<a href='%s'><img src='%s'></a>",
|
||||
downloadURL,
|
||||
|
@ -559,7 +559,7 @@ func (pr *publishRequest) serveFileDownload(des *search.DescribedBlob) {
|
|||
}
|
||||
mime := ""
|
||||
if fileinfo != nil && fileinfo.IsImage() {
|
||||
mime = fileinfo.MimeType
|
||||
mime = fileinfo.MIMEType
|
||||
}
|
||||
dh := &DownloadHandler{
|
||||
Fetcher: pr.ph.Storage,
|
||||
|
|
|
@ -126,7 +126,7 @@ func (fi *FakeIndex) GetOwnerClaims(permaNode, owner *blobref.BlobRef) (search.C
|
|||
return fi.ownerClaims[permaNode.String()+"/"+owner.String()], nil
|
||||
}
|
||||
|
||||
func (fi *FakeIndex) GetBlobMimeType(blob *blobref.BlobRef) (mime string, size int64, err error) {
|
||||
func (fi *FakeIndex) GetBlobMIMEType(blob *blobref.BlobRef) (mime string, size int64, err error) {
|
||||
fi.lk.Lock()
|
||||
defer fi.lk.Unlock()
|
||||
bs := blob.String()
|
||||
|
|
Loading…
Reference in New Issue