mirror of
https://github.com/octoleo/syncthing.git
synced 2025-02-02 11:58:28 +00:00
lib/db, lib/discover: Minor cleanup (#8217)
This commit is contained in:
parent
7b63254a35
commit
26eaedc491
@ -133,13 +133,13 @@ var (
|
||||
update0to3Folder = "UpdateSchema0to3"
|
||||
invalid = "invalid"
|
||||
slashPrefixed = "/notgood"
|
||||
haveUpdate0to3 map[protocol.DeviceID]fileList
|
||||
haveUpdate0to3 map[protocol.DeviceID][]protocol.FileInfo
|
||||
)
|
||||
|
||||
func init() {
|
||||
remoteDevice0, _ = protocol.DeviceIDFromString("AIR6LPZ-7K4PTTV-UXQSMUU-CPQ5YWH-OEDFIIQ-JUG777G-2YQXXR5-YD6AWQR")
|
||||
remoteDevice1, _ = protocol.DeviceIDFromString("I6KAH76-66SLLLB-5PFXSOA-UFJCDZC-YAOMLEK-CP2GB32-BV5RQST-3PSROAU")
|
||||
haveUpdate0to3 = map[protocol.DeviceID]fileList{
|
||||
haveUpdate0to3 = map[protocol.DeviceID][]protocol.FileInfo{
|
||||
protocol.LocalDeviceID: {
|
||||
protocol.FileInfo{Name: "a", Version: protocol.Vector{Counters: []protocol.Counter{{ID: myID, Value: 1000}}}, Blocks: genBlocks(1)},
|
||||
protocol.FileInfo{Name: slashPrefixed, Version: protocol.Vector{Counters: []protocol.Counter{{ID: myID, Value: 1000}}}, Blocks: genBlocks(1)},
|
||||
|
@ -512,17 +512,3 @@ func (fv FileVersion) copy() FileVersion {
|
||||
n.InvalidDevices = append([][]byte{}, fv.InvalidDevices...)
|
||||
return n
|
||||
}
|
||||
|
||||
type fileList []protocol.FileInfo
|
||||
|
||||
func (fl fileList) Len() int {
|
||||
return len(fl)
|
||||
}
|
||||
|
||||
func (fl fileList) Swap(a, b int) {
|
||||
fl[a], fl[b] = fl[b], fl[a]
|
||||
}
|
||||
|
||||
func (fl fileList) Less(a, b int) bool {
|
||||
return fl[a].Name < fl[b].Name
|
||||
}
|
||||
|
@ -420,26 +420,18 @@ type contextClient struct {
|
||||
}
|
||||
|
||||
func (c *contextClient) Get(ctx context.Context, url string) (*http.Response, error) {
|
||||
// For <go1.13 compatibility. Use the following commented line once that
|
||||
// isn't required anymore.
|
||||
// req, err := http.NewRequestWithContext(ctx, "GET", url, nil)
|
||||
req, err := http.NewRequest("GET", url, nil)
|
||||
req, err := http.NewRequestWithContext(ctx, "GET", url, nil)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
req.Cancel = ctx.Done()
|
||||
return c.Client.Do(req)
|
||||
}
|
||||
|
||||
func (c *contextClient) Post(ctx context.Context, url, ctype string, data io.Reader) (*http.Response, error) {
|
||||
// For <go1.13 compatibility. Use the following commented line once that
|
||||
// isn't required anymore.
|
||||
// req, err := http.NewRequestWithContext(ctx, "POST", url, data)
|
||||
req, err := http.NewRequest("POST", url, data)
|
||||
req, err := http.NewRequestWithContext(ctx, "POST", url, data)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
req.Cancel = ctx.Done()
|
||||
req.Header.Set("Content-Type", ctype)
|
||||
return c.Client.Do(req)
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user