This commit is contained in:
Brad Fitzpatrick 2014-03-16 22:23:13 -07:00
commit e44d49a557
3 changed files with 37 additions and 36 deletions

View File

@ -438,41 +438,6 @@ func (bb *Builder) SetSymlinkTarget(target string) *Builder {
return bb
}
func mixedArrayFromString(s string) []interface{} {
buf := []byte(s)
var name []interface{}
n := 0
for n < len(buf) {
part, offset := nextStringOrByte(buf[n:])
name = append(name, part)
n += offset
}
return name
}
func nextStringOrByte(b []byte) (interface{}, int) {
n := 0
var s []byte
for n < len(b) {
r, size := utf8.DecodeRune(b[n:])
if r == utf8.RuneError {
// If we already have a UTF8 string segment, return it
if len(s) > 0 {
return string(s), n
}
// Return the single byte and an offset of 1
return b[n], 1
}
n += size // We have consumed size bytes
c := make([]byte, utf8.RuneLen(r))
_ = utf8.EncodeRune(c, r)
s = append(s, c...)
}
return string(s), n
}
// IsClaimType returns whether this blob builder is for a type
// which should be signed. (a "claim" or "permanode")
func (bb *Builder) IsClaimType() bool {

View File

@ -36,6 +36,7 @@ import (
"strings"
"sync"
"time"
"unicode/utf8"
"camlistore.org/pkg/blob"
"camlistore.org/pkg/types"
@ -348,6 +349,41 @@ func stringFromMixedArray(parts []interface{}) string {
return buf.String()
}
func mixedArrayFromString(s string) []interface{} {
buf := []byte(s)
var name []interface{}
n := 0
for n < len(buf) {
part, offset := nextStringOrByte(buf[n:])
name = append(name, part)
n += offset
}
return name
}
func nextStringOrByte(b []byte) (interface{}, int) {
n := 0
var s []byte
for n < len(b) {
r, size := utf8.DecodeRune(b[n:])
if r == utf8.RuneError {
// If we already have a UTF8 string segment, return it
if len(s) > 0 {
return string(s), n
}
// Return the single byte and an offset of 1
return b[n], 1
}
n += size // We have consumed size bytes
c := make([]byte, utf8.RuneLen(r))
_ = utf8.EncodeRune(c, r)
s = append(s, c...)
}
return string(s), n
}
func (ss *superset) SumPartsSize() (size uint64) {
for _, part := range ss.Parts {
size += uint64(part.Size)

View File

@ -344,7 +344,7 @@ cam.IndexPageReact = React.createClass({
var blobref = goog.object.getAnyKey(this.state.selection);
var data = new cam.BlobItemReactData(blobref, this.searchSession_.getCurrentResults().description.meta);
if (!data.m.type != 'permanode') {
if (data.m.camliType != 'permanode') {
return null;
}