Files
Michal Klos e23737705e fix: [backport][OCISDEV-873] *WithoutTrashbin space editor roles render files read-only in Web frontend (#12351)
fix: [OCISDEV-873] *WithoutTrashbin space editor roles render files read-only in Web frontend (#12346)

* fix: [OCISDEV-873] *WithoutTrashbin space editor roles render files as read-only in Web frontend

* fix: ci after godata bump

ocis CI bumped github.com/CiscoM31/godata from v1.0.10 → v1.0.11 as a transitive dependency of the reva bump. The new godata version parses "mail add 10 (invalid operator) as a parse error → 400 instead of unsupported operation → 501.

* fix ci: more precise role

* fix: bump reva to pull fix merged into reva
2026-05-21 17:51:05 +02:00

78 lines
1.8 KiB
Go

package time
import (
"encoding/binary"
"fmt"
"reflect"
"time"
"github.com/shamaton/msgpack/v2/def"
"github.com/shamaton/msgpack/v2/ext"
)
var StreamDecoder = new(timeStreamDecoder)
type timeStreamDecoder struct{}
var _ ext.StreamDecoder = (*timeStreamDecoder)(nil)
func (td *timeStreamDecoder) Code() int8 {
return def.TimeStamp
}
func (td *timeStreamDecoder) IsType(code byte, innerType int8, dataLength int) bool {
switch code {
case def.Fixext4, def.Fixext8:
return innerType == td.Code()
case def.Ext8:
return innerType == td.Code() && dataLength == 12
}
return false
}
func (td *timeStreamDecoder) ToValue(code byte, data []byte, k reflect.Kind) (interface{}, error) {
switch code {
case def.Fixext4:
if len(data) < def.Byte4 {
return zero, def.ErrTooShortBytes
}
v := time.Unix(int64(binary.BigEndian.Uint32(data)), 0)
if decodeAsLocal {
return v, nil
}
return v.UTC(), nil
case def.Fixext8:
if len(data) < def.Byte8 {
return zero, def.ErrTooShortBytes
}
data64 := binary.BigEndian.Uint64(data)
nano := int64(data64 >> 34)
if nano > 999999999 {
return zero, fmt.Errorf("in timestamp 64 formats, nanoseconds must not be larger than 999999999 : %d", nano)
}
v := time.Unix(int64(data64&0x00000003ffffffff), nano)
if decodeAsLocal {
return v, nil
}
return v.UTC(), nil
case def.Ext8:
if len(data) < def.Byte4+def.Byte8 {
return zero, def.ErrTooShortBytes
}
nano := binary.BigEndian.Uint32(data[:4])
if nano > 999999999 {
return zero, fmt.Errorf("in timestamp 96 formats, nanoseconds must not be larger than 999999999 : %d", nano)
}
sec := binary.BigEndian.Uint64(data[4:12])
v := time.Unix(int64(sec), int64(nano))
if decodeAsLocal {
return v, nil
}
return v.UTC(), nil
}
return zero, fmt.Errorf("should not reach this line!! code %x decoding %v", code, k)
}