From 1550888bc3be1b12753c1526a66517cb7a7a0ac2 Mon Sep 17 00:00:00 2001 From: Nick Craig-Wood Date: Tue, 4 Sep 2018 20:27:48 +0100 Subject: [PATCH] hubic: fix uploads - fixes #2524 Uploads were broken because chunk size was set to zero. This was a consequence of the backend config re-organization which meant that chunk size had lost its default. Sharing some backend config between swift and hubic fixes the problem and means hubic gains its own --hubic-chunk-size flag. --- backend/hubic/hubic.go | 4 ++-- backend/swift/swift.go | 19 +++++++++++-------- 2 files changed, 13 insertions(+), 10 deletions(-) diff --git a/backend/hubic/hubic.go b/backend/hubic/hubic.go index 6419315fc..955ab7d3d 100644 --- a/backend/hubic/hubic.go +++ b/backend/hubic/hubic.go @@ -60,13 +60,13 @@ func init() { log.Fatalf("Failed to configure token: %v", err) } }, - Options: []fs.Option{{ + Options: append([]fs.Option{{ Name: config.ConfigClientID, Help: "Hubic Client Id\nLeave blank normally.", }, { Name: config.ConfigClientSecret, Help: "Hubic Client Secret\nLeave blank normally.", - }}, + }}, swift.SharedOptions...), }) } diff --git a/backend/swift/swift.go b/backend/swift/swift.go index 57c008307..a490b2077 100644 --- a/backend/swift/swift.go +++ b/backend/swift/swift.go @@ -31,13 +31,21 @@ const ( listChunks = 1000 // chunk size to read directory listings ) +// SharedOptions are shared between swift and hubic +var SharedOptions = []fs.Option{{ + Name: "chunk_size", + Help: "Above this size files will be chunked into a _segments container.", + Default: fs.SizeSuffix(5 * 1024 * 1024 * 1024), + Advanced: true, +}} + // Register with Fs func init() { fs.Register(&fs.RegInfo{ Name: "swift", Description: "Openstack Swift (Rackspace Cloud Files, Memset Memstore, OVH)", NewFs: NewFs, - Options: []fs.Option{{ + Options: append([]fs.Option{{ Name: "env_auth", Help: "Get swift credentials from environment variables in standard OpenStack form.", Default: false, @@ -134,12 +142,7 @@ func init() { Help: "OVH Public Cloud Archive", Value: "pca", }}, - }, { - Name: "chunk_size", - Help: "Above this size files will be chunked into a _segments container.", - Default: fs.SizeSuffix(5 * 1024 * 1024 * 1024), - Advanced: true, - }}, + }}, SharedOptions...), }) } @@ -291,7 +294,7 @@ func swiftConnection(opt *Options, name string) (*swift.Connection, error) { return c, nil } -// NewFsWithConnection contstructs an Fs from the path, container:path +// NewFsWithConnection constructs an Fs from the path, container:path // and authenticated connection. // // if noCheckContainer is set then the Fs won't check the container