forked from TrueCloudLab/rclone
Remove builds conditional on go1.7 since that is now guaranteed #2154
Old fallback code was deleted and the go1.7 style code inlined where appropriate.
This commit is contained in:
parent
e5be471ce0
commit
be54fd8f70
35 changed files with 45 additions and 157 deletions
|
@ -1,7 +1,4 @@
|
||||||
// Package azureblob provides an interface to the Microsoft Azure blob object storage system
|
// Package azureblob provides an interface to the Microsoft Azure blob object storage system
|
||||||
|
|
||||||
// +build go1.7
|
|
||||||
|
|
||||||
package azureblob
|
package azureblob
|
||||||
|
|
||||||
import (
|
import (
|
||||||
|
|
|
@ -2,9 +2,6 @@
|
||||||
//
|
//
|
||||||
// Automatically generated - DO NOT EDIT
|
// Automatically generated - DO NOT EDIT
|
||||||
// Regenerate with: make gen_tests
|
// Regenerate with: make gen_tests
|
||||||
|
|
||||||
// +build go1.7
|
|
||||||
|
|
||||||
package azureblob_test
|
package azureblob_test
|
||||||
|
|
||||||
import (
|
import (
|
||||||
|
|
|
@ -1,6 +0,0 @@
|
||||||
// Build for unsupported platforms to stop go complaining
|
|
||||||
// about "no buildable Go source files "
|
|
||||||
|
|
||||||
// +build !go1.7
|
|
||||||
|
|
||||||
package azureblob
|
|
2
backend/cache/cache.go
vendored
2
backend/cache/cache.go
vendored
|
@ -1,4 +1,4 @@
|
||||||
// +build !plan9,go1.7
|
// +build !plan9
|
||||||
|
|
||||||
package cache
|
package cache
|
||||||
|
|
||||||
|
|
2
backend/cache/cache_internal_test.go
vendored
2
backend/cache/cache_internal_test.go
vendored
|
@ -1,4 +1,4 @@
|
||||||
// +build !plan9,go1.7
|
// +build !plan9
|
||||||
|
|
||||||
package cache_test
|
package cache_test
|
||||||
|
|
||||||
|
|
2
backend/cache/cache_mount_unix_test.go
vendored
2
backend/cache/cache_mount_unix_test.go
vendored
|
@ -1,4 +1,4 @@
|
||||||
// +build !plan9,!windows,go1.7
|
// +build !plan9,!windows
|
||||||
|
|
||||||
package cache_test
|
package cache_test
|
||||||
|
|
||||||
|
|
2
backend/cache/cache_mount_windows_test.go
vendored
2
backend/cache/cache_mount_windows_test.go
vendored
|
@ -1,4 +1,4 @@
|
||||||
// +build windows,go1.7
|
// +build windows
|
||||||
|
|
||||||
package cache_test
|
package cache_test
|
||||||
|
|
||||||
|
|
2
backend/cache/cache_test.go
vendored
2
backend/cache/cache_test.go
vendored
|
@ -3,7 +3,7 @@
|
||||||
// Automatically generated - DO NOT EDIT
|
// Automatically generated - DO NOT EDIT
|
||||||
// Regenerate with: make gen_tests
|
// Regenerate with: make gen_tests
|
||||||
|
|
||||||
// +build !plan9,go1.7
|
// +build !plan9
|
||||||
|
|
||||||
package cache_test
|
package cache_test
|
||||||
|
|
||||||
|
|
2
backend/cache/cache_unsupported.go
vendored
2
backend/cache/cache_unsupported.go
vendored
|
@ -1,6 +1,6 @@
|
||||||
// Build for cache for unsupported platforms to stop go complaining
|
// Build for cache for unsupported platforms to stop go complaining
|
||||||
// about "no buildable Go source files "
|
// about "no buildable Go source files "
|
||||||
|
|
||||||
// +build plan9 !go1.7
|
// +build plan9
|
||||||
|
|
||||||
package cache
|
package cache
|
||||||
|
|
2
backend/cache/directory.go
vendored
2
backend/cache/directory.go
vendored
|
@ -1,4 +1,4 @@
|
||||||
// +build !plan9,go1.7
|
// +build !plan9
|
||||||
|
|
||||||
package cache
|
package cache
|
||||||
|
|
||||||
|
|
2
backend/cache/handle.go
vendored
2
backend/cache/handle.go
vendored
|
@ -1,4 +1,4 @@
|
||||||
// +build !plan9,go1.7
|
// +build !plan9
|
||||||
|
|
||||||
package cache
|
package cache
|
||||||
|
|
||||||
|
|
2
backend/cache/object.go
vendored
2
backend/cache/object.go
vendored
|
@ -1,4 +1,4 @@
|
||||||
// +build !plan9,go1.7
|
// +build !plan9
|
||||||
|
|
||||||
package cache
|
package cache
|
||||||
|
|
||||||
|
|
2
backend/cache/plex.go
vendored
2
backend/cache/plex.go
vendored
|
@ -1,4 +1,4 @@
|
||||||
// +build !plan9,go1.7
|
// +build !plan9
|
||||||
|
|
||||||
package cache
|
package cache
|
||||||
|
|
||||||
|
|
2
backend/cache/storage_memory.go
vendored
2
backend/cache/storage_memory.go
vendored
|
@ -1,4 +1,4 @@
|
||||||
// +build !plan9,go1.7
|
// +build !plan9
|
||||||
|
|
||||||
package cache
|
package cache
|
||||||
|
|
||||||
|
|
2
backend/cache/storage_persistent.go
vendored
2
backend/cache/storage_persistent.go
vendored
|
@ -1,4 +1,4 @@
|
||||||
// +build !plan9,go1.7
|
// +build !plan9
|
||||||
|
|
||||||
package cache
|
package cache
|
||||||
|
|
||||||
|
|
|
@ -1,7 +1,4 @@
|
||||||
// Package dropbox provides an interface to Dropbox object storage
|
// Package dropbox provides an interface to Dropbox object storage
|
||||||
|
|
||||||
// +build go1.7
|
|
||||||
|
|
||||||
package dropbox
|
package dropbox
|
||||||
|
|
||||||
// FIXME dropbox for business would be quite easy to add
|
// FIXME dropbox for business would be quite easy to add
|
||||||
|
|
|
@ -2,9 +2,6 @@
|
||||||
//
|
//
|
||||||
// Automatically generated - DO NOT EDIT
|
// Automatically generated - DO NOT EDIT
|
||||||
// Regenerate with: make gen_tests
|
// Regenerate with: make gen_tests
|
||||||
|
|
||||||
// +build go1.7
|
|
||||||
|
|
||||||
package dropbox_test
|
package dropbox_test
|
||||||
|
|
||||||
import (
|
import (
|
||||||
|
|
|
@ -1,6 +0,0 @@
|
||||||
// Build for unsupported platforms to stop go complaining about "no
|
|
||||||
// buildable Go source files "
|
|
||||||
|
|
||||||
// +build !go1.7
|
|
||||||
|
|
||||||
package dropbox
|
|
|
@ -2,9 +2,6 @@
|
||||||
//
|
//
|
||||||
// It treats HTML pages served from the endpoint as directory
|
// It treats HTML pages served from the endpoint as directory
|
||||||
// listings, and includes any links found as files.
|
// listings, and includes any links found as files.
|
||||||
|
|
||||||
// +build go1.7
|
|
||||||
|
|
||||||
package http
|
package http
|
||||||
|
|
||||||
import (
|
import (
|
||||||
|
|
|
@ -1,6 +0,0 @@
|
||||||
// Build for mount for unsupported platforms to stop go complaining
|
|
||||||
// about "no buildable Go source files "
|
|
||||||
|
|
||||||
// +build !go1.7
|
|
||||||
|
|
||||||
package http
|
|
|
@ -1,7 +1,7 @@
|
||||||
// Package qingstor provides an interface to QingStor object storage
|
// Package qingstor provides an interface to QingStor object storage
|
||||||
// Home: https://www.qingcloud.com/
|
// Home: https://www.qingcloud.com/
|
||||||
|
|
||||||
// +build !plan9,go1.7
|
// +build !plan9
|
||||||
|
|
||||||
package qingstor
|
package qingstor
|
||||||
|
|
||||||
|
|
|
@ -3,7 +3,7 @@
|
||||||
// Automatically generated - DO NOT EDIT
|
// Automatically generated - DO NOT EDIT
|
||||||
// Regenerate with: make gen_tests
|
// Regenerate with: make gen_tests
|
||||||
|
|
||||||
// +build !plan9,go1.7
|
// +build !plan9
|
||||||
|
|
||||||
package qingstor_test
|
package qingstor_test
|
||||||
|
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
// Build for unsupported platforms to stop go complaining
|
// Build for unsupported platforms to stop go complaining
|
||||||
// about "no buildable Go source files "
|
// about "no buildable Go source files "
|
||||||
|
|
||||||
// +build plan9 !go1.7
|
// +build plan9
|
||||||
|
|
||||||
package qingstor
|
package qingstor
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
// Upload object to QingStor
|
// Upload object to QingStor
|
||||||
|
|
||||||
// +build !plan9,go1.7
|
// +build !plan9
|
||||||
|
|
||||||
package qingstor
|
package qingstor
|
||||||
|
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
// +build !plan9,go1.7
|
// +build !plan9
|
||||||
|
|
||||||
package cachestats
|
package cachestats
|
||||||
|
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
// Build for cache for unsupported platforms to stop go complaining
|
// Build for cache for unsupported platforms to stop go complaining
|
||||||
// about "no buildable Go source files "
|
// about "no buildable Go source files "
|
||||||
|
|
||||||
// +build plan9 !go1.7
|
// +build plan9
|
||||||
|
|
||||||
package cachestats
|
package cachestats
|
||||||
|
|
|
@ -1,5 +1,3 @@
|
||||||
// +build go1.7
|
|
||||||
|
|
||||||
package restic
|
package restic
|
||||||
|
|
||||||
import (
|
import (
|
||||||
|
|
|
@ -108,6 +108,16 @@ func setDefaults(a, b interface{}) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// dial with context and timeouts
|
||||||
|
func dialContextTimeout(ctx context.Context, network, address string, ci *fs.ConfigInfo) (net.Conn, error) {
|
||||||
|
dialer := NewDialer(ci)
|
||||||
|
c, err := dialer.DialContext(ctx, network, address)
|
||||||
|
if err != nil {
|
||||||
|
return c, err
|
||||||
|
}
|
||||||
|
return newTimeoutConn(c, ci.Timeout)
|
||||||
|
}
|
||||||
|
|
||||||
// NewTransport returns an http.RoundTripper with the correct timeouts
|
// NewTransport returns an http.RoundTripper with the correct timeouts
|
||||||
func NewTransport(ci *fs.ConfigInfo) http.RoundTripper {
|
func NewTransport(ci *fs.ConfigInfo) http.RoundTripper {
|
||||||
noTransport.Do(func() {
|
noTransport.Do(func() {
|
||||||
|
@ -121,13 +131,11 @@ func NewTransport(ci *fs.ConfigInfo) http.RoundTripper {
|
||||||
t.ResponseHeaderTimeout = ci.Timeout
|
t.ResponseHeaderTimeout = ci.Timeout
|
||||||
t.TLSClientConfig = &tls.Config{InsecureSkipVerify: ci.InsecureSkipVerify}
|
t.TLSClientConfig = &tls.Config{InsecureSkipVerify: ci.InsecureSkipVerify}
|
||||||
t.DisableCompression = ci.NoGzip
|
t.DisableCompression = ci.NoGzip
|
||||||
// Set in http_old.go initTransport
|
t.DialContext = func(ctx context.Context, network, addr string) (net.Conn, error) {
|
||||||
// t.Dial
|
return dialContextTimeout(ctx, network, addr, ci)
|
||||||
// Set in http_new.go initTransport
|
}
|
||||||
// t.DialContext
|
t.IdleConnTimeout = 60 * time.Second
|
||||||
// t.IdelConnTimeout
|
t.ExpectContinueTimeout = ci.ConnectTimeout
|
||||||
// t.ExpectContinueTimeout
|
|
||||||
initTransport(ci, t)
|
|
||||||
// Wrap that http.Transport in our own transport
|
// Wrap that http.Transport in our own transport
|
||||||
transport = newTransport(ci, t)
|
transport = newTransport(ci, t)
|
||||||
})
|
})
|
||||||
|
|
|
@ -1,33 +0,0 @@
|
||||||
// HTTP parts go1.7+
|
|
||||||
|
|
||||||
//+build go1.7
|
|
||||||
|
|
||||||
package fshttp
|
|
||||||
|
|
||||||
import (
|
|
||||||
"context"
|
|
||||||
"net"
|
|
||||||
"net/http"
|
|
||||||
"time"
|
|
||||||
|
|
||||||
"github.com/ncw/rclone/fs"
|
|
||||||
)
|
|
||||||
|
|
||||||
// dial with context and timeouts
|
|
||||||
func dialContextTimeout(ctx context.Context, network, address string, ci *fs.ConfigInfo) (net.Conn, error) {
|
|
||||||
dialer := NewDialer(ci)
|
|
||||||
c, err := dialer.DialContext(ctx, network, address)
|
|
||||||
if err != nil {
|
|
||||||
return c, err
|
|
||||||
}
|
|
||||||
return newTimeoutConn(c, ci.Timeout)
|
|
||||||
}
|
|
||||||
|
|
||||||
// Initialise the http.Transport for go1.7+
|
|
||||||
func initTransport(ci *fs.ConfigInfo, t *http.Transport) {
|
|
||||||
t.DialContext = func(ctx context.Context, network, addr string) (net.Conn, error) {
|
|
||||||
return dialContextTimeout(ctx, network, addr, ci)
|
|
||||||
}
|
|
||||||
t.IdleConnTimeout = 60 * time.Second
|
|
||||||
t.ExpectContinueTimeout = ci.ConnectTimeout
|
|
||||||
}
|
|
|
@ -1,29 +0,0 @@
|
||||||
// HTTP parts pre go1.7
|
|
||||||
|
|
||||||
//+build !go1.7
|
|
||||||
|
|
||||||
package fshttp
|
|
||||||
|
|
||||||
import (
|
|
||||||
"net"
|
|
||||||
"net/http"
|
|
||||||
|
|
||||||
"github.com/ncw/rclone/fs"
|
|
||||||
)
|
|
||||||
|
|
||||||
// dial with timeouts
|
|
||||||
func dialTimeout(network, address string, ci *fs.ConfigInfo) (net.Conn, error) {
|
|
||||||
dialer := NewDialer(ci)
|
|
||||||
c, err := dialer.Dial(network, address)
|
|
||||||
if err != nil {
|
|
||||||
return c, err
|
|
||||||
}
|
|
||||||
return newTimeoutConn(c, ci.Timeout)
|
|
||||||
}
|
|
||||||
|
|
||||||
// Initialise the http.Transport for pre go1.7
|
|
||||||
func initTransport(ci *fs.ConfigInfo, t *http.Transport) {
|
|
||||||
t.Dial = func(network, addr string) (net.Conn, error) {
|
|
||||||
return dialTimeout(network, addr, ci)
|
|
||||||
}
|
|
||||||
}
|
|
|
@ -1,5 +1,3 @@
|
||||||
//+build go1.7
|
|
||||||
|
|
||||||
package fshttp
|
package fshttp
|
||||||
|
|
||||||
import (
|
import (
|
||||||
|
|
|
@ -9,6 +9,7 @@ package rc
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"encoding/json"
|
"encoding/json"
|
||||||
|
"io"
|
||||||
"net/http"
|
"net/http"
|
||||||
"strings"
|
"strings"
|
||||||
|
|
||||||
|
@ -66,6 +67,13 @@ func (s *server) serve() {
|
||||||
s.srv.Wait()
|
s.srv.Wait()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// WriteJSON writes JSON in out to w
|
||||||
|
func WriteJSON(w io.Writer, out Params) error {
|
||||||
|
enc := json.NewEncoder(w)
|
||||||
|
enc.SetIndent("", "\t")
|
||||||
|
return enc.Encode(out)
|
||||||
|
}
|
||||||
|
|
||||||
// handler reads incoming requests and dispatches them
|
// handler reads incoming requests and dispatches them
|
||||||
func (s *server) handler(w http.ResponseWriter, r *http.Request) {
|
func (s *server) handler(w http.ResponseWriter, r *http.Request) {
|
||||||
path := strings.Trim(r.URL.Path, "/")
|
path := strings.Trim(r.URL.Path, "/")
|
||||||
|
|
|
@ -1,15 +0,0 @@
|
||||||
//+build go1.7
|
|
||||||
|
|
||||||
package rc
|
|
||||||
|
|
||||||
import (
|
|
||||||
"encoding/json"
|
|
||||||
"io"
|
|
||||||
)
|
|
||||||
|
|
||||||
// WriteJSON writes JSON in out to w
|
|
||||||
func WriteJSON(w io.Writer, out Params) error {
|
|
||||||
enc := json.NewEncoder(w)
|
|
||||||
enc.SetIndent("", "\t")
|
|
||||||
return enc.Encode(out)
|
|
||||||
}
|
|
|
@ -1,14 +0,0 @@
|
||||||
//+build !go1.7
|
|
||||||
|
|
||||||
package rc
|
|
||||||
|
|
||||||
import (
|
|
||||||
"encoding/json"
|
|
||||||
"io"
|
|
||||||
)
|
|
||||||
|
|
||||||
// WriteJSON writes JSON in out to w
|
|
||||||
func WriteJSON(w io.Writer, out Params) error {
|
|
||||||
enc := json.NewEncoder(w)
|
|
||||||
return enc.Encode(out)
|
|
||||||
}
|
|
|
@ -150,7 +150,7 @@ func main() {
|
||||||
generateTestProgram(t, fns, "S3")
|
generateTestProgram(t, fns, "S3")
|
||||||
generateTestProgram(t, fns, "Drive")
|
generateTestProgram(t, fns, "Drive")
|
||||||
generateTestProgram(t, fns, "GoogleCloudStorage")
|
generateTestProgram(t, fns, "GoogleCloudStorage")
|
||||||
generateTestProgram(t, fns, "Dropbox", buildConstraint("go1.7"))
|
generateTestProgram(t, fns, "Dropbox")
|
||||||
generateTestProgram(t, fns, "AmazonCloudDrive", buildConstraint("acd"))
|
generateTestProgram(t, fns, "AmazonCloudDrive", buildConstraint("acd"))
|
||||||
generateTestProgram(t, fns, "OneDrive")
|
generateTestProgram(t, fns, "OneDrive")
|
||||||
generateTestProgram(t, fns, "Hubic")
|
generateTestProgram(t, fns, "Hubic")
|
||||||
|
@ -162,10 +162,10 @@ func main() {
|
||||||
generateTestProgram(t, fns, "Sftp", buildConstraint("!plan9,go1.8"))
|
generateTestProgram(t, fns, "Sftp", buildConstraint("!plan9,go1.8"))
|
||||||
generateTestProgram(t, fns, "FTP")
|
generateTestProgram(t, fns, "FTP")
|
||||||
generateTestProgram(t, fns, "Box")
|
generateTestProgram(t, fns, "Box")
|
||||||
generateTestProgram(t, fns, "QingStor", buildConstraint("!plan9,go1.7"))
|
generateTestProgram(t, fns, "QingStor", buildConstraint("!plan9"))
|
||||||
generateTestProgram(t, fns, "AzureBlob", buildConstraint("go1.7"))
|
generateTestProgram(t, fns, "AzureBlob")
|
||||||
generateTestProgram(t, fns, "Pcloud")
|
generateTestProgram(t, fns, "Pcloud")
|
||||||
generateTestProgram(t, fns, "Webdav")
|
generateTestProgram(t, fns, "Webdav")
|
||||||
generateTestProgram(t, fns, "Cache", buildConstraint("!plan9,go1.7"))
|
generateTestProgram(t, fns, "Cache", buildConstraint("!plan9"))
|
||||||
log.Printf("Done")
|
log.Printf("Done")
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Reference in a new issue