@@ -313,6 +313,7 @@ func (s *service) Serve(ctx context.Context) error {
|
||||
configBuilder.registerDevice("/rest/config/devices/:id")
|
||||
configBuilder.registerDefaultFolder("/rest/config/defaults/folder")
|
||||
configBuilder.registerDefaultDevice("/rest/config/defaults/device")
|
||||
configBuilder.registerDefaultIgnores("/rest/config/defaults/ignores")
|
||||
configBuilder.registerOptions("/rest/config/options")
|
||||
configBuilder.registerLDAP("/rest/config/ldap")
|
||||
configBuilder.registerGUI("/rest/config/gui")
|
||||
|
||||
@@ -229,6 +229,28 @@ func (c *configMuxBuilder) registerDefaultDevice(path string) {
|
||||
})
|
||||
}
|
||||
|
||||
func (c *configMuxBuilder) registerDefaultIgnores(path string) {
|
||||
c.HandlerFunc(http.MethodGet, path, func(w http.ResponseWriter, _ *http.Request) {
|
||||
sendJSON(w, c.cfg.DefaultIgnores())
|
||||
})
|
||||
|
||||
c.HandlerFunc(http.MethodPut, path, func(w http.ResponseWriter, r *http.Request) {
|
||||
var ignores config.Ignores
|
||||
if err := unmarshalTo(r.Body, &ignores); err != nil {
|
||||
http.Error(w, err.Error(), http.StatusBadRequest)
|
||||
return
|
||||
}
|
||||
waiter, err := c.cfg.Modify(func(cfg *config.Configuration) {
|
||||
cfg.Defaults.Ignores = ignores
|
||||
})
|
||||
if err != nil {
|
||||
http.Error(w, err.Error(), http.StatusInternalServerError)
|
||||
return
|
||||
}
|
||||
c.finish(w, waiter)
|
||||
})
|
||||
}
|
||||
|
||||
func (c *configMuxBuilder) registerOptions(path string) {
|
||||
c.HandlerFunc(http.MethodGet, path, func(w http.ResponseWriter, _ *http.Request) {
|
||||
sendJSON(w, c.cfg.Options())
|
||||
|
||||
@@ -621,3 +621,9 @@ func ensureZeroForNodefault(empty interface{}, target interface{}) {
|
||||
return len(v) > 0
|
||||
})
|
||||
}
|
||||
|
||||
func (i Ignores) Copy() Ignores {
|
||||
out := Ignores{Lines: make([]string, len(i.Lines))}
|
||||
copy(out.Lines, i.Lines)
|
||||
return out
|
||||
}
|
||||
|
||||
+264
-44
@@ -69,8 +69,9 @@ func (m *Configuration) XXX_DiscardUnknown() {
|
||||
var xxx_messageInfo_Configuration proto.InternalMessageInfo
|
||||
|
||||
type Defaults struct {
|
||||
Folder FolderConfiguration `protobuf:"bytes,1,opt,name=folder,proto3" json:"folder" xml:"folder"`
|
||||
Device DeviceConfiguration `protobuf:"bytes,2,opt,name=device,proto3" json:"device" xml:"device"`
|
||||
Folder FolderConfiguration `protobuf:"bytes,1,opt,name=folder,proto3" json:"folder" xml:"folder"`
|
||||
Device DeviceConfiguration `protobuf:"bytes,2,opt,name=device,proto3" json:"device" xml:"device"`
|
||||
Ignores Ignores `protobuf:"bytes,3,opt,name=ignores,proto3" json:"ignores" xml:"ignores"`
|
||||
}
|
||||
|
||||
func (m *Defaults) Reset() { *m = Defaults{} }
|
||||
@@ -106,56 +107,98 @@ func (m *Defaults) XXX_DiscardUnknown() {
|
||||
|
||||
var xxx_messageInfo_Defaults proto.InternalMessageInfo
|
||||
|
||||
type Ignores struct {
|
||||
Lines []string `protobuf:"bytes,1,rep,name=lines,proto3" json:"lines" xml:"line"`
|
||||
}
|
||||
|
||||
func (m *Ignores) Reset() { *m = Ignores{} }
|
||||
func (m *Ignores) String() string { return proto.CompactTextString(m) }
|
||||
func (*Ignores) ProtoMessage() {}
|
||||
func (*Ignores) Descriptor() ([]byte, []int) {
|
||||
return fileDescriptor_baadf209193dc627, []int{2}
|
||||
}
|
||||
func (m *Ignores) XXX_Unmarshal(b []byte) error {
|
||||
return m.Unmarshal(b)
|
||||
}
|
||||
func (m *Ignores) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) {
|
||||
if deterministic {
|
||||
return xxx_messageInfo_Ignores.Marshal(b, m, deterministic)
|
||||
} else {
|
||||
b = b[:cap(b)]
|
||||
n, err := m.MarshalToSizedBuffer(b)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return b[:n], nil
|
||||
}
|
||||
}
|
||||
func (m *Ignores) XXX_Merge(src proto.Message) {
|
||||
xxx_messageInfo_Ignores.Merge(m, src)
|
||||
}
|
||||
func (m *Ignores) XXX_Size() int {
|
||||
return m.ProtoSize()
|
||||
}
|
||||
func (m *Ignores) XXX_DiscardUnknown() {
|
||||
xxx_messageInfo_Ignores.DiscardUnknown(m)
|
||||
}
|
||||
|
||||
var xxx_messageInfo_Ignores proto.InternalMessageInfo
|
||||
|
||||
func init() {
|
||||
proto.RegisterType((*Configuration)(nil), "config.Configuration")
|
||||
proto.RegisterType((*Defaults)(nil), "config.Defaults")
|
||||
proto.RegisterType((*Ignores)(nil), "config.Ignores")
|
||||
}
|
||||
|
||||
func init() { proto.RegisterFile("lib/config/config.proto", fileDescriptor_baadf209193dc627) }
|
||||
|
||||
var fileDescriptor_baadf209193dc627 = []byte{
|
||||
// 654 bytes of a gzipped FileDescriptorProto
|
||||
0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0x84, 0x94, 0xcd, 0x6e, 0xd3, 0x40,
|
||||
0x10, 0xc7, 0xed, 0xa6, 0x4d, 0xda, 0xed, 0x17, 0x32, 0x08, 0x5c, 0x3e, 0xbc, 0x61, 0x15, 0x50,
|
||||
0x41, 0xa5, 0x95, 0xca, 0x05, 0x71, 0x23, 0x44, 0x94, 0x0a, 0x24, 0x2a, 0xa3, 0x22, 0xe0, 0x82,
|
||||
0x92, 0x78, 0xeb, 0xae, 0x94, 0xd8, 0x96, 0xbd, 0xae, 0xda, 0x47, 0xe0, 0x86, 0x78, 0x02, 0x4e,
|
||||
0x48, 0xdc, 0x79, 0x88, 0xdc, 0x92, 0x23, 0xa7, 0x95, 0x9a, 0xdc, 0x7c, 0xf4, 0x91, 0x13, 0xda,
|
||||
0x0f, 0xbb, 0xb6, 0x6a, 0xe0, 0x64, 0xcf, 0xfc, 0xff, 0xf3, 0x9b, 0xd5, 0x78, 0xc7, 0xe0, 0xc6,
|
||||
0x80, 0xf4, 0x76, 0xfa, 0xbe, 0x77, 0x44, 0x5c, 0xf5, 0xd8, 0x0e, 0x42, 0x9f, 0xfa, 0x46, 0x5d,
|
||||
0x46, 0x37, 0x5b, 0x05, 0xc3, 0x91, 0x3f, 0x70, 0x70, 0x28, 0x83, 0x38, 0xec, 0x52, 0xe2, 0x7b,
|
||||
0xd2, 0x5d, 0x72, 0x39, 0xf8, 0x84, 0xf4, 0x71, 0x95, 0xeb, 0x6e, 0xc1, 0xe5, 0xc6, 0xa4, 0xca,
|
||||
0x82, 0x0a, 0x96, 0x81, 0xd3, 0x0d, 0xaa, 0x3c, 0xf7, 0x0a, 0x1e, 0x3f, 0xe0, 0x42, 0x54, 0x65,
|
||||
0xdb, 0x28, 0xda, 0x7a, 0x11, 0x0e, 0x4f, 0xb0, 0xa3, 0xa4, 0x25, 0x7c, 0x4a, 0xe5, 0x2b, 0xfa,
|
||||
0xde, 0x00, 0xab, 0xcf, 0x8b, 0xd5, 0x86, 0x0d, 0x1a, 0x27, 0x38, 0x8c, 0x88, 0xef, 0x99, 0x7a,
|
||||
0x53, 0xdf, 0x5c, 0x68, 0x3f, 0x49, 0x18, 0xcc, 0x52, 0x29, 0x83, 0xc6, 0xe9, 0x70, 0xf0, 0x14,
|
||||
0xa9, 0x78, 0xab, 0x4b, 0x69, 0x88, 0x7e, 0x33, 0x58, 0x23, 0x1e, 0x4d, 0xc6, 0xad, 0x95, 0x62,
|
||||
0xde, 0xce, 0xaa, 0x8c, 0x77, 0xa0, 0x21, 0x87, 0x17, 0x99, 0x73, 0xcd, 0xda, 0xe6, 0xf2, 0xee,
|
||||
0xad, 0x6d, 0x35, 0xed, 0x17, 0x22, 0x5d, 0x3a, 0x41, 0x1b, 0x8e, 0x18, 0xd4, 0x78, 0x53, 0x55,
|
||||
0x93, 0x32, 0xb8, 0x22, 0x9a, 0xca, 0x18, 0xd9, 0x99, 0xc0, 0xb9, 0x72, 0xdc, 0x91, 0x59, 0x2b,
|
||||
0x73, 0x3b, 0x22, 0xfd, 0x17, 0xae, 0xa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f, 0x8f, 0x89, 0xe7, 0x16, 0xde, 0x2e, 0x7e, 0x63, 0xbd, 0xba, 0xf8, 0x67, 0x3d,
|
||||
0xfe, 0x13, 0x00, 0x00, 0xff, 0xff, 0x50, 0xe9, 0xd5, 0x50, 0xb6, 0x05, 0x00, 0x00,
|
||||
// 709 bytes of a gzipped FileDescriptorProto
|
||||
0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0x84, 0x94, 0x4b, 0x6f, 0xd3, 0x40,
|
||||
0x10, 0xc7, 0xe3, 0xa6, 0x8d, 0x9b, 0xed, 0x0b, 0x19, 0x44, 0x5d, 0x1e, 0xde, 0xb0, 0x0a, 0x28,
|
||||
0xa0, 0x3e, 0xa4, 0x72, 0xa9, 0xb8, 0x11, 0x22, 0x4a, 0x55, 0x24, 0x2a, 0xa3, 0x22, 0xe0, 0x82,
|
||||
0x92, 0x78, 0xeb, 0xae, 0x94, 0xd8, 0x96, 0xed, 0x54, 0xed, 0x91, 0x23, 0x37, 0xc4, 0x27, 0xe0,
|
||||
0x84, 0xc4, 0x37, 0xe9, 0xad, 0x39, 0x72, 0x5a, 0xa9, 0xcd, 0xcd, 0x47, 0x1f, 0x39, 0xa1, 0x7d,
|
||||
0x39, 0xb6, 0x6a, 0xe0, 0x94, 0xcc, 0xfc, 0xff, 0xf3, 0xdb, 0xd5, 0xec, 0x8c, 0xc1, 0xea, 0x80,
|
||||
0xf4, 0xb6, 0xfa, 0xbe, 0x77, 0x44, 0x5c, 0xf9, 0xb3, 0x19, 0x84, 0x7e, 0xec, 0x1b, 0x35, 0x11,
|
||||
0xdd, 0x69, 0xe6, 0x0c, 0x47, 0xfe, 0xc0, 0xc1, 0xa1, 0x08, 0x46, 0x61, 0x37, 0x26, 0xbe, 0x27,
|
||||
0xdc, 0x05, 0x97, 0x83, 0x4f, 0x48, 0x1f, 0x97, 0xb9, 0x1e, 0xe4, 0x5c, 0xee, 0x88, 0x94, 0x59,
|
||||
0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99,
|
||||
0xee, 0x88, 0xa0, 0x6f, 0xe3, 0x26, 0x93, 0x6c, 0x26, 0x18, 0x1f, 0xc0, 0x2c, 0x7b, 0x51, 0x73,
|
||||
0x8e, 0x43, 0xd7, 0x14, 0xf4, 0x75, 0xe7, 0xf9, 0x41, 0x91, 0xfa, 0x44, 0x52, 0x67, 0x99, 0x94,
|
||||
0x50, 0xc8, 0xcb, 0x52, 0x0a, 0x01, 0xe7, 0xb2, 0x80, 0x81, 0xb9, 0x6a, 0x73, 0xcd, 0x78, 0x0f,
|
||||
0x74, 0x39, 0x08, 0x66, 0x8d, 0xd3, 0xef, 0x29, 0xfa, 0x1b, 0x91, 0x2e, 0x1e, 0xd0, 0x50, 0x7d,
|
||||
0x90, 0x45, 0x29, 0x85, 0x4b, 0x9c, 0x2d, 0x63, 0x64, 0x2b, 0xc5, 0xf8, 0xa9, 0x81, 0x15, 0xe2,
|
||||
0x7a, 0x7e, 0x88, 0x9d, 0x4f, 0xaa, 0xd3, 0x3a, 0xef, 0xf4, 0xed, 0xec, 0x08, 0x39, 0x5b, 0xa2,
|
||||
0xe3, 0xed, 0x63, 0x09, 0xbf, 0x15, 0xe2, 0xa1, 0x1f, 0xe3, 0x3d, 0x51, 0xdc, 0xc9, 0x3a, 0xbe,
|
||||
0xc6, 0x4f, 0x2a, 0x11, 0x51, 0x72, 0xd1, 0xbc, 0x59, 0x92, 0x4f, 0x2f, 0x9a, 0xa5, 0x2c, 0x7b,
|
||||
0x99, 0x14, 0x62, 0xe3, 0x8b, 0x06, 0x56, 0x02, 0xec, 0x39, 0xc4, 0x73, 0xb3, 0xbb, 0xce, 0xff,
|
||||
0xf3, 0xae, 0xaf, 0x64, 0xa7, 0xcd, 0x0e, 0x0e, 0x42, 0xdc, 0xef, 0xc6, 0xd8, 0x39, 0x10, 0x00,
|
||||
0xc9, 0x4c, 0x28, 0xd4, 0x36, 0x52, 0x0a, 0xef, 0xf3, 0x4b, 0x07, 0x79, 0x6d, 0xdd, 0x1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xc4, 0xc7, 0xa3,
|
||||
0xde, 0x66, 0xdf, 0x1f, 0x6e, 0x45, 0x67, 0x5e, 0x3f, 0x3e, 0x26, 0x9e, 0x9b, 0xfb, 0x37, 0xfd,
|
||||
0x9a, 0xf6, 0x6a, 0xfc, 0xd3, 0xf9, 0xf4, 0x4f, 0x00, 0x00, 0x00, 0xff, 0xff, 0x77, 0x7d, 0xcb,
|
||||
0x2a, 0x3d, 0x06, 0x00, 0x00,
|
||||
}
|
||||
|
||||
func (m *Configuration) Marshal() (dAtA []byte, err error) {
|
||||
@@ -302,6 +345,16 @@ func (m *Defaults) MarshalToSizedBuffer(dAtA []byte) (int, error) {
|
||||
_ = i
|
||||
var l int
|
||||
_ = l
|
||||
{
|
||||
size, err := m.Ignores.MarshalToSizedBuffer(dAtA[:i])
|
||||
if err != nil {
|
||||
return 0, err
|
||||
}
|
||||
i -= size
|
||||
i = encodeVarintConfig(dAtA, i, uint64(size))
|
||||
}
|
||||
i--
|
||||
dAtA[i] = 0x1a
|
||||
{
|
||||
size, err := m.Device.MarshalToSizedBuffer(dAtA[:i])
|
||||
if err != nil {
|
||||
@@ -325,6 +378,38 @@ func (m *Defaults) MarshalToSizedBuffer(dAtA []byte) (int, error) {
|
||||
return len(dAtA) - i, nil
|
||||
}
|
||||
|
||||
func (m *Ignores) Marshal() (dAtA []byte, err error) {
|
||||
size := m.ProtoSize()
|
||||
dAtA = make([]byte, size)
|
||||
n, err := m.MarshalToSizedBuffer(dAtA[:size])
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return dAtA[:n], nil
|
||||
}
|
||||
|
||||
func (m *Ignores) MarshalTo(dAtA []byte) (int, error) {
|
||||
size := m.ProtoSize()
|
||||
return m.MarshalToSizedBuffer(dAtA[:size])
|
||||
}
|
||||
|
||||
func (m *Ignores) MarshalToSizedBuffer(dAtA []byte) (int, error) {
|
||||
i := len(dAtA)
|
||||
_ = i
|
||||
var l int
|
||||
_ = l
|
||||
if len(m.Lines) > 0 {
|
||||
for iNdEx := len(m.Lines) - 1; iNdEx >= 0; iNdEx-- {
|
||||
i -= len(m.Lines[iNdEx])
|
||||
copy(dAtA[i:], m.Lines[iNdEx])
|
||||
i = encodeVarintConfig(dAtA, i, uint64(len(m.Lines[iNdEx])))
|
||||
i--
|
||||
dAtA[i] = 0xa
|
||||
}
|
||||
}
|
||||
return len(dAtA) - i, nil
|
||||
}
|
||||
|
||||
func encodeVarintConfig(dAtA []byte, offset int, v uint64) int {
|
||||
offset -= sovConfig(v)
|
||||
base := offset
|
||||
@@ -390,6 +475,23 @@ func (m *Defaults) ProtoSize() (n int) {
|
||||
n += 1 + l + sovConfig(uint64(l))
|
||||
l = m.Device.ProtoSize()
|
||||
n += 1 + l + sovConfig(uint64(l))
|
||||
l = m.Ignores.ProtoSize()
|
||||
n += 1 + l + sovConfig(uint64(l))
|
||||
return n
|
||||
}
|
||||
|
||||
func (m *Ignores) ProtoSize() (n int) {
|
||||
if m == nil {
|
||||
return 0
|
||||
}
|
||||
var l int
|
||||
_ = l
|
||||
if len(m.Lines) > 0 {
|
||||
for _, s := range m.Lines {
|
||||
l = len(s)
|
||||
n += 1 + l + sovConfig(uint64(l))
|
||||
}
|
||||
}
|
||||
return n
|
||||
}
|
||||
|
||||
@@ -831,6 +933,124 @@ func (m *Defaults) Unmarshal(dAtA []byte) error {
|
||||
return err
|
||||
}
|
||||
iNdEx = postIndex
|
||||
case 3:
|
||||
if wireType != 2 {
|
||||
return fmt.Errorf("proto: wrong wireType = %d for field Ignores", wireType)
|
||||
}
|
||||
var msglen int
|
||||
for shift := uint(0); ; shift += 7 {
|
||||
if shift >= 64 {
|
||||
return ErrIntOverflowConfig
|
||||
}
|
||||
if iNdEx >= l {
|
||||
return io.ErrUnexpectedEOF
|
||||
}
|
||||
b := dAtA[iNdEx]
|
||||
iNdEx++
|
||||
msglen |= int(b&0x7F) << shift
|
||||
if b < 0x80 {
|
||||
break
|
||||
}
|
||||
}
|
||||
if msglen < 0 {
|
||||
return ErrInvalidLengthConfig
|
||||
}
|
||||
postIndex := iNdEx + msglen
|
||||
if postIndex < 0 {
|
||||
return ErrInvalidLengthConfig
|
||||
}
|
||||
if postIndex > l {
|
||||
return io.ErrUnexpectedEOF
|
||||
}
|
||||
if err := m.Ignores.Unmarshal(dAtA[iNdEx:postIndex]); err != nil {
|
||||
return err
|
||||
}
|
||||
iNdEx = postIndex
|
||||
default:
|
||||
iNdEx = preIndex
|
||||
skippy, err := skipConfig(dAtA[iNdEx:])
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
if skippy < 0 {
|
||||
return ErrInvalidLengthConfig
|
||||
}
|
||||
if (iNdEx + skippy) < 0 {
|
||||
return ErrInvalidLengthConfig
|
||||
}
|
||||
if (iNdEx + skippy) > l {
|
||||
return io.ErrUnexpectedEOF
|
||||
}
|
||||
iNdEx += skippy
|
||||
}
|
||||
}
|
||||
|
||||
if iNdEx > l {
|
||||
return io.ErrUnexpectedEOF
|
||||
}
|
||||
return nil
|
||||
}
|
||||
func (m *Ignores) Unmarshal(dAtA []byte) error {
|
||||
l := len(dAtA)
|
||||
iNdEx := 0
|
||||
for iNdEx < l {
|
||||
preIndex := iNdEx
|
||||
var wire uint64
|
||||
for shift := uint(0); ; shift += 7 {
|
||||
if shift >= 64 {
|
||||
return ErrIntOverflowConfig
|
||||
}
|
||||
if iNdEx >= l {
|
||||
return io.ErrUnexpectedEOF
|
||||
}
|
||||
b := dAtA[iNdEx]
|
||||
iNdEx++
|
||||
wire |= uint64(b&0x7F) << shift
|
||||
if b < 0x80 {
|
||||
break
|
||||
}
|
||||
}
|
||||
fieldNum := int32(wire >> 3)
|
||||
wireType := int(wire & 0x7)
|
||||
if wireType == 4 {
|
||||
return fmt.Errorf("proto: Ignores: wiretype end group for non-group")
|
||||
}
|
||||
if fieldNum <= 0 {
|
||||
return fmt.Errorf("proto: Ignores: illegal tag %d (wire type %d)", fieldNum, wire)
|
||||
}
|
||||
switch fieldNum {
|
||||
case 1:
|
||||
if wireType != 2 {
|
||||
return fmt.Errorf("proto: wrong wireType = %d for field Lines", wireType)
|
||||
}
|
||||
var stringLen uint64
|
||||
for shift := uint(0); ; shift += 7 {
|
||||
if shift >= 64 {
|
||||
return ErrIntOverflowConfig
|
||||
}
|
||||
if iNdEx >= l {
|
||||
return io.ErrUnexpectedEOF
|
||||
}
|
||||
b := dAtA[iNdEx]
|
||||
iNdEx++
|
||||
stringLen |= uint64(b&0x7F) << shift
|
||||
if b < 0x80 {
|
||||
break
|
||||
}
|
||||
}
|
||||
intStringLen := int(stringLen)
|
||||
if intStringLen < 0 {
|
||||
return ErrInvalidLengthConfig
|
||||
}
|
||||
postIndex := iNdEx + intStringLen
|
||||
if postIndex < 0 {
|
||||
return ErrInvalidLengthConfig
|
||||
}
|
||||
if postIndex > l {
|
||||
return io.ErrUnexpectedEOF
|
||||
}
|
||||
m.Lines = append(m.Lines, string(dAtA[iNdEx:postIndex]))
|
||||
iNdEx = postIndex
|
||||
default:
|
||||
iNdEx = preIndex
|
||||
skippy, err := skipConfig(dAtA[iNdEx:])
|
||||
|
||||
@@ -113,6 +113,9 @@ func TestDefaultValues(t *testing.T) {
|
||||
Compression: protocol.CompressionMetadata,
|
||||
IgnoredFolders: []ObservedFolder{},
|
||||
},
|
||||
Ignores: Ignores{
|
||||
Lines: []string{},
|
||||
},
|
||||
},
|
||||
IgnoredDevices: []ObservedDevice{},
|
||||
}
|
||||
|
||||
@@ -40,6 +40,16 @@ type Wrapper struct {
|
||||
defaultFolderReturnsOnCall map[int]struct {
|
||||
result1 config.FolderConfiguration
|
||||
}
|
||||
DefaultIgnoresStub func() config.Ignores
|
||||
defaultIgnoresMutex sync.RWMutex
|
||||
defaultIgnoresArgsForCall []struct {
|
||||
}
|
||||
defaultIgnoresReturns struct {
|
||||
result1 config.Ignores
|
||||
}
|
||||
defaultIgnoresReturnsOnCall map[int]struct {
|
||||
result1 config.Ignores
|
||||
}
|
||||
DeviceStub func(protocol.DeviceID) (config.DeviceConfiguration, bool)
|
||||
deviceMutex sync.RWMutex
|
||||
deviceArgsForCall []struct {
|
||||
@@ -449,6 +459,59 @@ func (fake *Wrapper) DefaultFolderReturnsOnCall(i int, result1 config.FolderConf
|
||||
}{result1}
|
||||
}
|
||||
|
||||
func (fake *Wrapper) DefaultIgnores() config.Ignores {
|
||||
fake.defaultIgnoresMutex.Lock()
|
||||
ret, specificReturn := fake.defaultIgnoresReturnsOnCall[len(fake.defaultIgnoresArgsForCall)]
|
||||
fake.defaultIgnoresArgsForCall = append(fake.defaultIgnoresArgsForCall, struct {
|
||||
}{})
|
||||
stub := fake.DefaultIgnoresStub
|
||||
fakeReturns := fake.defaultIgnoresReturns
|
||||
fake.recordInvocation("DefaultIgnores", []interface{}{})
|
||||
fake.defaultIgnoresMutex.Unlock()
|
||||
if stub != nil {
|
||||
return stub()
|
||||
}
|
||||
if specificReturn {
|
||||
return ret.result1
|
||||
}
|
||||
return fakeReturns.result1
|
||||
}
|
||||
|
||||
func (fake *Wrapper) DefaultIgnoresCallCount() int {
|
||||
fake.defaultIgnoresMutex.RLock()
|
||||
defer fake.defaultIgnoresMutex.RUnlock()
|
||||
return len(fake.defaultIgnoresArgsForCall)
|
||||
}
|
||||
|
||||
func (fake *Wrapper) DefaultIgnoresCalls(stub func() config.Ignores) {
|
||||
fake.defaultIgnoresMutex.Lock()
|
||||
defer fake.defaultIgnoresMutex.Unlock()
|
||||
fake.DefaultIgnoresStub = stub
|
||||
}
|
||||
|
||||
func (fake *Wrapper) DefaultIgnoresReturns(result1 config.Ignores) {
|
||||
fake.defaultIgnoresMutex.Lock()
|
||||
defer fake.defaultIgnoresMutex.Unlock()
|
||||
fake.DefaultIgnoresStub = nil
|
||||
fake.defaultIgnoresReturns = struct {
|
||||
result1 config.Ignores
|
||||
}{result1}
|
||||
}
|
||||
|
||||
func (fake *Wrapper) DefaultIgnoresReturnsOnCall(i int, result1 config.Ignores) {
|
||||
fake.defaultIgnoresMutex.Lock()
|
||||
defer fake.defaultIgnoresMutex.Unlock()
|
||||
fake.DefaultIgnoresStub = nil
|
||||
if fake.defaultIgnoresReturnsOnCall == nil {
|
||||
fake.defaultIgnoresReturnsOnCall = make(map[int]struct {
|
||||
result1 config.Ignores
|
||||
})
|
||||
}
|
||||
fake.defaultIgnoresReturnsOnCall[i] = struct {
|
||||
result1 config.Ignores
|
||||
}{result1}
|
||||
}
|
||||
|
||||
func (fake *Wrapper) Device(arg1 protocol.DeviceID) (config.DeviceConfiguration, bool) {
|
||||
fake.deviceMutex.Lock()
|
||||
ret, specificReturn := fake.deviceReturnsOnCall[len(fake.deviceArgsForCall)]
|
||||
@@ -1752,6 +1815,8 @@ func (fake *Wrapper) Invocations() map[string][][]interface{} {
|
||||
defer fake.defaultDeviceMutex.RUnlock()
|
||||
fake.defaultFolderMutex.RLock()
|
||||
defer fake.defaultFolderMutex.RUnlock()
|
||||
fake.defaultIgnoresMutex.RLock()
|
||||
defer fake.defaultIgnoresMutex.RUnlock()
|
||||
fake.deviceMutex.RLock()
|
||||
defer fake.deviceMutex.RUnlock()
|
||||
fake.deviceListMutex.RLock()
|
||||
|
||||
@@ -100,6 +100,7 @@ type Wrapper interface {
|
||||
GUI() GUIConfiguration
|
||||
LDAP() LDAPConfiguration
|
||||
Options() OptionsConfiguration
|
||||
DefaultIgnores() Ignores
|
||||
|
||||
Folder(id string) (FolderConfiguration, bool)
|
||||
Folders() map[string]FolderConfiguration
|
||||
@@ -437,6 +438,13 @@ func (w *wrapper) GUI() GUIConfiguration {
|
||||
return w.cfg.GUI.Copy()
|
||||
}
|
||||
|
||||
// DefaultIgnores returns the list of ignore patterns to be used by default on folders.
|
||||
func (w *wrapper) DefaultIgnores() Ignores {
|
||||
w.mut.Lock()
|
||||
defer w.mut.Unlock()
|
||||
return w.cfg.Defaults.Ignores.Copy()
|
||||
}
|
||||
|
||||
// IgnoredDevice returns whether or not connection attempts from the given
|
||||
// device should be silently ignored.
|
||||
func (w *wrapper) IgnoredDevice(id protocol.DeviceID) bool {
|
||||
|
||||
+9
-6
@@ -1651,6 +1651,11 @@ func (m *model) handleAutoAccepts(deviceID protocol.DeviceID, folder protocol.Fo
|
||||
|
||||
if len(ccDeviceInfos.remote.EncryptionPasswordToken) > 0 || len(ccDeviceInfos.local.EncryptionPasswordToken) > 0 {
|
||||
fcfg.Type = config.FolderTypeReceiveEncrypted
|
||||
} else {
|
||||
ignores := m.cfg.DefaultIgnores()
|
||||
if err := m.setIgnores(fcfg, ignores.Lines); err != nil {
|
||||
l.Warnf("Failed to apply default ignores to auto-accepted folder %s at path %s: %v", folder.Description(), fcfg.Path, err)
|
||||
}
|
||||
}
|
||||
|
||||
l.Infof("Auto-accepted %s folder %s at path %s", deviceID, folder.Description(), fcfg.Path)
|
||||
@@ -2035,11 +2040,6 @@ func (m *model) LoadIgnores(folder string) ([]string, []string, error) {
|
||||
return nil, nil, nil
|
||||
}
|
||||
|
||||
// On creation a new folder with ignore patterns validly has no marker yet.
|
||||
if err := cfg.CheckPath(); err != nil && err != config.ErrMarkerMissing {
|
||||
return nil, nil, err
|
||||
}
|
||||
|
||||
if !ignoresOk {
|
||||
ignores = ignore.New(cfg.Filesystem())
|
||||
}
|
||||
@@ -2081,7 +2081,10 @@ func (m *model) SetIgnores(folder string, content []string) error {
|
||||
if !ok {
|
||||
return fmt.Errorf("folder %s does not exist", cfg.Description())
|
||||
}
|
||||
return m.setIgnores(cfg, content)
|
||||
}
|
||||
|
||||
func (m *model) setIgnores(cfg config.FolderConfiguration, content []string) error {
|
||||
err := cfg.CheckPath()
|
||||
if err == config.ErrPathMissing {
|
||||
if err = cfg.CreateRoot(); err != nil {
|
||||
@@ -2099,7 +2102,7 @@ func (m *model) SetIgnores(folder string, content []string) error {
|
||||
}
|
||||
|
||||
m.fmut.RLock()
|
||||
runner, ok := m.folderRunners[folder]
|
||||
runner, ok := m.folderRunners[cfg.ID]
|
||||
m.fmut.RUnlock()
|
||||
if ok {
|
||||
runner.ScheduleScan()
|
||||
|
||||
@@ -1515,7 +1515,7 @@ func TestIgnores(t *testing.T) {
|
||||
t.Error("No error")
|
||||
}
|
||||
|
||||
// Invalid path, marker should be missing, hence returns an error.
|
||||
// Invalid path, treated like no patterns at all.
|
||||
fcfg := config.FolderConfiguration{ID: "fresh", Path: "XXX"}
|
||||
ignores := ignore.New(fcfg.Filesystem(), ignore.WithCache(m.cfg.Options().CacheIgnoredFiles))
|
||||
m.fmut.Lock()
|
||||
@@ -1524,8 +1524,8 @@ func TestIgnores(t *testing.T) {
|
||||
m.fmut.Unlock()
|
||||
|
||||
_, _, err = m.LoadIgnores("fresh")
|
||||
if err == nil {
|
||||
t.Error("No error")
|
||||
if err != nil {
|
||||
t.Error("Got error for inexistent folder path")
|
||||
}
|
||||
|
||||
// Repeat tests with paused folder
|
||||
|
||||
Reference in New Issue
Block a user