mirror of
https://github.com/rclone/rclone.git
synced 2024-11-29 03:48:27 +08:00
Factor UserAgent to fs and move Version to fs
This commit is contained in:
parent
e40b09fe61
commit
c1a245d1c8
3
Makefile
3
Makefile
|
@ -45,8 +45,7 @@ serve:
|
||||||
tag:
|
tag:
|
||||||
@echo "Old tag is $(LAST_TAG)"
|
@echo "Old tag is $(LAST_TAG)"
|
||||||
@echo "New tag is $(NEW_TAG)"
|
@echo "New tag is $(NEW_TAG)"
|
||||||
echo -e "package main\n const Version = \"$(NEW_TAG)\"\n" | gofmt > version.go
|
echo -e "package fs\n const Version = \"$(NEW_TAG)\"\n" | gofmt > fs/version.go
|
||||||
cp -av version.go rclonetest/version.go
|
|
||||||
perl -lpe 's/VERSION/${NEW_TAG}/g; s/DATE/'`date -I`'/g;' docs/content/downloads.md.in > docs/content/downloads.md
|
perl -lpe 's/VERSION/${NEW_TAG}/g; s/DATE/'`date -I`'/g;' docs/content/downloads.md.in > docs/content/downloads.md
|
||||||
git tag $(NEW_TAG)
|
git tag $(NEW_TAG)
|
||||||
@echo "Add this to changelog in README.md"
|
@echo "Add this to changelog in README.md"
|
||||||
|
|
|
@ -930,7 +930,7 @@ func (o *FsObjectDrive) Storable() bool {
|
||||||
// Open an object for read
|
// Open an object for read
|
||||||
func (o *FsObjectDrive) Open() (in io.ReadCloser, err error) {
|
func (o *FsObjectDrive) Open() (in io.ReadCloser, err error) {
|
||||||
req, _ := http.NewRequest("GET", o.url, nil)
|
req, _ := http.NewRequest("GET", o.url, nil)
|
||||||
req.Header.Set("User-Agent", "rclone/1.0")
|
req.Header.Set("User-Agent", fs.UserAgent)
|
||||||
res, err := o.drive.client.Do(req)
|
res, err := o.drive.client.Do(req)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
|
|
6
fs/fs.go
6
fs/fs.go
|
@ -10,6 +10,12 @@ import (
|
||||||
"time"
|
"time"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
// Constants
|
||||||
|
const (
|
||||||
|
// User agent for Fs which can set it
|
||||||
|
UserAgent = "rclone/" + Version
|
||||||
|
)
|
||||||
|
|
||||||
// Globals
|
// Globals
|
||||||
var (
|
var (
|
||||||
// Filesystem registry
|
// Filesystem registry
|
||||||
|
|
|
@ -1,3 +1,3 @@
|
||||||
package main
|
package fs
|
||||||
|
|
||||||
const Version = "v1.01"
|
const Version = "v1.01"
|
|
@ -60,7 +60,7 @@ Making a release
|
||||||
* cd ..
|
* cd ..
|
||||||
* make tag
|
* make tag
|
||||||
* edit README.md
|
* edit README.md
|
||||||
* git commit version.go rclonetest/version.go README.md docs/content/downloads.md
|
* git commit fs/version.go README.md docs/content/downloads.md
|
||||||
* make retag
|
* make retag
|
||||||
* . ~/bin/go-cross
|
* . ~/bin/go-cross
|
||||||
* make cross
|
* make cross
|
||||||
|
|
|
@ -228,7 +228,7 @@ Syntax: [options] subcommand <parameters> <parameters...>
|
||||||
|
|
||||||
Subcommands:
|
Subcommands:
|
||||||
|
|
||||||
`, Version)
|
`, fs.Version)
|
||||||
for i := range Commands {
|
for i := range Commands {
|
||||||
cmd := &Commands[i]
|
cmd := &Commands[i]
|
||||||
fmt.Fprintf(os.Stderr, " %s %s\n", cmd.Name, cmd.ArgsHelp)
|
fmt.Fprintf(os.Stderr, " %s %s\n", cmd.Name, cmd.ArgsHelp)
|
||||||
|
@ -329,7 +329,7 @@ func StartStats() {
|
||||||
func main() {
|
func main() {
|
||||||
ParseFlags()
|
ParseFlags()
|
||||||
if *version {
|
if *version {
|
||||||
fmt.Printf("rclone %s\n", Version)
|
fmt.Printf("rclone %s\n", fs.Version)
|
||||||
os.Exit(0)
|
os.Exit(0)
|
||||||
}
|
}
|
||||||
command, args := ParseCommand()
|
command, args := ParseCommand()
|
||||||
|
|
|
@ -299,7 +299,7 @@ directory under it and perform tests on it, deleting it at the end.
|
||||||
|
|
||||||
Options:
|
Options:
|
||||||
|
|
||||||
`, Version)
|
`, fs.Version)
|
||||||
pflag.PrintDefaults()
|
pflag.PrintDefaults()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -316,7 +316,7 @@ func main() {
|
||||||
pflag.Usage = syntaxError
|
pflag.Usage = syntaxError
|
||||||
pflag.Parse()
|
pflag.Parse()
|
||||||
if *version {
|
if *version {
|
||||||
fmt.Printf("rclonetest %s\n", Version)
|
fmt.Printf("rclonetest %s\n", fs.Version)
|
||||||
os.Exit(0)
|
os.Exit(0)
|
||||||
}
|
}
|
||||||
fs.LoadConfig()
|
fs.LoadConfig()
|
||||||
|
|
|
@ -110,6 +110,7 @@ func swiftConnection(name string) (*swift.Connection, error) {
|
||||||
UserName: userName,
|
UserName: userName,
|
||||||
ApiKey: apiKey,
|
ApiKey: apiKey,
|
||||||
AuthUrl: authUrl,
|
AuthUrl: authUrl,
|
||||||
|
UserAgent: fs.UserAgent,
|
||||||
}
|
}
|
||||||
err := c.Authenticate()
|
err := c.Authenticate()
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
|
|
@ -1,3 +0,0 @@
|
||||||
package main
|
|
||||||
|
|
||||||
const Version = "v1.01"
|
|
Loading…
Reference in New Issue
Block a user