diff --git a/common_test.go b/common_test.go index 0f3795d5b..f46b6a8da 100644 --- a/common_test.go +++ b/common_test.go @@ -25,10 +25,10 @@ func newTestModel() *TestModel { } } -func (t *TestModel) Index(deviceID DeviceID, folder string, files []FileInfo) { +func (t *TestModel) Index(deviceID DeviceID, folder string, files []FileInfo, flags uint32, options []Option) { } -func (t *TestModel) IndexUpdate(deviceID DeviceID, folder string, files []FileInfo) { +func (t *TestModel) IndexUpdate(deviceID DeviceID, folder string, files []FileInfo, flags uint32, options []Option) { } func (t *TestModel) Request(deviceID DeviceID, folder, name string, offset int64, size int, hash []byte, flags uint32, options []Option) ([]byte, error) { diff --git a/nativemodel_darwin.go b/nativemodel_darwin.go index 6001af694..502a71f23 100644 --- a/nativemodel_darwin.go +++ b/nativemodel_darwin.go @@ -12,18 +12,18 @@ type nativeModel struct { next Model } -func (m nativeModel) Index(deviceID DeviceID, folder string, files []FileInfo) { +func (m nativeModel) Index(deviceID DeviceID, folder string, files []FileInfo, flags uint32, options []Option) { for i := range files { files[i].Name = norm.NFD.String(files[i].Name) } - m.next.Index(deviceID, folder, files) + m.next.Index(deviceID, folder, files, flags, options) } -func (m nativeModel) IndexUpdate(deviceID DeviceID, folder string, files []FileInfo) { +func (m nativeModel) IndexUpdate(deviceID DeviceID, folder string, files []FileInfo, flags uint32, options []Option) { for i := range files { files[i].Name = norm.NFD.String(files[i].Name) } - m.next.IndexUpdate(deviceID, folder, files) + m.next.IndexUpdate(deviceID, folder, files, flags, options) } func (m nativeModel) Request(deviceID DeviceID, folder string, name string, offset int64, size int, hash []byte, flags uint32, options []Option) ([]byte, error) { diff --git a/nativemodel_unix.go b/nativemodel_unix.go index 5f7b2e2c4..21585e308 100644 --- a/nativemodel_unix.go +++ b/nativemodel_unix.go @@ -10,12 +10,12 @@ type nativeModel struct { next Model } -func (m nativeModel) Index(deviceID DeviceID, folder string, files []FileInfo) { - m.next.Index(deviceID, folder, files) +func (m nativeModel) Index(deviceID DeviceID, folder string, files []FileInfo, flags uint32, options []Option) { + m.next.Index(deviceID, folder, files, flags, options) } -func (m nativeModel) IndexUpdate(deviceID DeviceID, folder string, files []FileInfo) { - m.next.IndexUpdate(deviceID, folder, files) +func (m nativeModel) IndexUpdate(deviceID DeviceID, folder string, files []FileInfo, flags uint32, options []Option) { + m.next.IndexUpdate(deviceID, folder, files, flags, options) } func (m nativeModel) Request(deviceID DeviceID, folder string, name string, offset int64, size int, hash []byte, flags uint32, options []Option) ([]byte, error) { diff --git a/nativemodel_windows.go b/nativemodel_windows.go index 4859cbaab..951f5b7e6 100644 --- a/nativemodel_windows.go +++ b/nativemodel_windows.go @@ -24,7 +24,7 @@ type nativeModel struct { next Model } -func (m nativeModel) Index(deviceID DeviceID, folder string, files []FileInfo) { +func (m nativeModel) Index(deviceID DeviceID, folder string, files []FileInfo, flags uint32, options []Option) { for i, f := range files { if strings.ContainsAny(f.Name, disallowedCharacters) { if f.IsDeleted() { @@ -37,10 +37,10 @@ func (m nativeModel) Index(deviceID DeviceID, folder string, files []FileInfo) { } files[i].Name = filepath.FromSlash(f.Name) } - m.next.Index(deviceID, folder, files) + m.next.Index(deviceID, folder, files, flags, options) } -func (m nativeModel) IndexUpdate(deviceID DeviceID, folder string, files []FileInfo) { +func (m nativeModel) IndexUpdate(deviceID DeviceID, folder string, files []FileInfo, flags uint32, options []Option) { for i, f := range files { if strings.ContainsAny(f.Name, disallowedCharacters) { if f.IsDeleted() { @@ -53,7 +53,7 @@ func (m nativeModel) IndexUpdate(deviceID DeviceID, folder string, files []FileI } files[i].Name = filepath.FromSlash(files[i].Name) } - m.next.IndexUpdate(deviceID, folder, files) + m.next.IndexUpdate(deviceID, folder, files, flags, options) } func (m nativeModel) Request(deviceID DeviceID, folder string, name string, offset int64, size int, hash []byte, flags uint32, options []Option) ([]byte, error) { diff --git a/protocol.go b/protocol.go index 7e2658775..7d742a7fa 100644 --- a/protocol.go +++ b/protocol.go @@ -66,9 +66,9 @@ type pongMessage struct{ EmptyMessage } type Model interface { // An index was received from the peer device - Index(deviceID DeviceID, folder string, files []FileInfo) + Index(deviceID DeviceID, folder string, files []FileInfo, flags uint32, options []Option) // An index update was received from the peer device - IndexUpdate(deviceID DeviceID, folder string, files []FileInfo) + IndexUpdate(deviceID DeviceID, folder string, files []FileInfo, flags uint32, options []Option) // A request was made by the peer device Request(deviceID DeviceID, folder string, name string, offset int64, size int, hash []byte, flags uint32, options []Option) ([]byte, error) // A cluster configuration message was received @@ -80,8 +80,8 @@ type Model interface { type Connection interface { ID() DeviceID Name() string - Index(folder string, files []FileInfo) error - IndexUpdate(folder string, files []FileInfo) error + Index(folder string, files []FileInfo, flags uint32, options []Option) error + IndexUpdate(folder string, files []FileInfo, flags uint32, options []Option) error Request(folder string, name string, offset int64, size int, hash []byte, flags uint32, options []Option) ([]byte, error) ClusterConfig(config ClusterConfigMessage) Statistics() Statistics @@ -169,7 +169,7 @@ func (c *rawConnection) Name() string { } // Index writes the list of file information to the connected peer device -func (c *rawConnection) Index(folder string, idx []FileInfo) error { +func (c *rawConnection) Index(folder string, idx []FileInfo, flags uint32, options []Option) error { select { case <-c.closed: return ErrClosed @@ -177,15 +177,17 @@ func (c *rawConnection) Index(folder string, idx []FileInfo) error { } c.idxMut.Lock() c.send(-1, messageTypeIndex, IndexMessage{ - Folder: folder, - Files: idx, + Folder: folder, + Files: idx, + Flags: flags, + Options: options, }) c.idxMut.Unlock() return nil } // IndexUpdate writes the list of file information to the connected peer device as an update -func (c *rawConnection) IndexUpdate(folder string, idx []FileInfo) error { +func (c *rawConnection) IndexUpdate(folder string, idx []FileInfo, flags uint32, options []Option) error { select { case <-c.closed: return ErrClosed @@ -193,8 +195,10 @@ func (c *rawConnection) IndexUpdate(folder string, idx []FileInfo) error { } c.idxMut.Lock() c.send(-1, messageTypeIndexUpdate, IndexMessage{ - Folder: folder, - Files: idx, + Folder: folder, + Files: idx, + Flags: flags, + Options: options, }) c.idxMut.Unlock() return nil @@ -463,16 +467,16 @@ func (c *rawConnection) readMessage() (hdr header, msg encodable, err error) { func (c *rawConnection) handleIndex(im IndexMessage) { if debug { - l.Debugf("Index(%v, %v, %d files)", c.id, im.Folder, len(im.Files)) + l.Debugf("Index(%v, %v, %d file, flags %x, opts: %s)", c.id, im.Folder, len(im.Files), im.Flags, im.Options) } - c.receiver.Index(c.id, im.Folder, filterIndexMessageFiles(im.Files)) + c.receiver.Index(c.id, im.Folder, filterIndexMessageFiles(im.Files), im.Flags, im.Options) } func (c *rawConnection) handleIndexUpdate(im IndexMessage) { if debug { - l.Debugf("queueing IndexUpdate(%v, %v, %d files)", c.id, im.Folder, len(im.Files)) + l.Debugf("queueing IndexUpdate(%v, %v, %d files, flags %x, opts: %s)", c.id, im.Folder, len(im.Files), im.Flags, im.Options) } - c.receiver.IndexUpdate(c.id, im.Folder, filterIndexMessageFiles(im.Files)) + c.receiver.IndexUpdate(c.id, im.Folder, filterIndexMessageFiles(im.Files), im.Flags, im.Options) } func filterIndexMessageFiles(fs []FileInfo) []FileInfo { diff --git a/protocol_test.go b/protocol_test.go index c660ba327..3ff1042cb 100644 --- a/protocol_test.go +++ b/protocol_test.go @@ -229,8 +229,8 @@ func TestClose(t *testing.T) { t.Error("Ping should not return true") } - c0.Index("default", nil) - c0.Index("default", nil) + c0.Index("default", nil, 0, nil) + c0.Index("default", nil, 0, nil) if _, err := c0.Request("default", "foo", 0, 0, nil, 0, nil); err == nil { t.Error("Request should return an error") diff --git a/wireformat.go b/wireformat.go index 23d347e1b..9411955ba 100644 --- a/wireformat.go +++ b/wireformat.go @@ -20,7 +20,7 @@ func (c wireFormatConnection) Name() string { return c.next.Name() } -func (c wireFormatConnection) Index(folder string, fs []FileInfo) error { +func (c wireFormatConnection) Index(folder string, fs []FileInfo, flags uint32, options []Option) error { var myFs = make([]FileInfo, len(fs)) copy(myFs, fs) @@ -28,10 +28,10 @@ func (c wireFormatConnection) Index(folder string, fs []FileInfo) error { myFs[i].Name = norm.NFC.String(filepath.ToSlash(myFs[i].Name)) } - return c.next.Index(folder, myFs) + return c.next.Index(folder, myFs, flags, options) } -func (c wireFormatConnection) IndexUpdate(folder string, fs []FileInfo) error { +func (c wireFormatConnection) IndexUpdate(folder string, fs []FileInfo, flags uint32, options []Option) error { var myFs = make([]FileInfo, len(fs)) copy(myFs, fs) @@ -39,7 +39,7 @@ func (c wireFormatConnection) IndexUpdate(folder string, fs []FileInfo) error { myFs[i].Name = norm.NFC.String(filepath.ToSlash(myFs[i].Name)) } - return c.next.IndexUpdate(folder, myFs) + return c.next.IndexUpdate(folder, myFs, flags, options) } func (c wireFormatConnection) Request(folder, name string, offset int64, size int, hash []byte, flags uint32, options []Option) ([]byte, error) {