| 1 | package filesscip-go gomod github.com/tombuildsstuff/giovanni . `github.com/tombuildsstuff/giovanni/storage/2018-03-28/file/files`/ |
| 2 | |
| 3 | import ( |
| 4 | "contextscip-go gomod github.com/golang/go/src go1.13 context/" |
| 5 | "fmtscip-go gomod github.com/golang/go/src go1.13 fmt/" |
| 6 | "stringsscip-go gomod github.com/golang/go/src go1.13 strings/" |
| 7 | "timescip-go gomod github.com/golang/go/src go1.13 time/" |
| 8 | |
| 9 | "github.com/Azure/go-autorest/autorestscip-go gomod github.com/Azure/go-autorest/autorest v0.11.19 `github.com/Azure/go-autorest/autorest`/" |
| 10 | ) |
| 11 | |
| 12 | type CopyAndWaitResultscip-go gomod github.com/tombuildsstuff/giovanni . `github.com/tombuildsstuff/giovanni/storage/2018-03-28/file/files`/CopyAndWaitResult# struct { |
| 13 | autorestscip-go gomod github.com/Azure/go-autorest/autorest v0.11.19 `github.com/Azure/go-autorest/autorest`/.Responsescip-go gomod github.com/tombuildsstuff/giovanni . `github.com/tombuildsstuff/giovanni/storage/2018-03-28/file/files`/CopyAndWaitResult#Response. |
| 14 | |
| 15 | CopyIDscip-go gomod github.com/tombuildsstuff/giovanni . `github.com/tombuildsstuff/giovanni/storage/2018-03-28/file/files`/CopyAndWaitResult#CopyID. string |
| 16 | } |
| 17 | |
| 18 | const DefaultCopyPollDurationscip-go gomod github.com/tombuildsstuff/giovanni . `github.com/tombuildsstuff/giovanni/storage/2018-03-28/file/files`/DefaultCopyPollDuration. = 15 * timescip-go gomod github.com/golang/go/src go1.13 time/.Secondscip-go gomod github.com/golang/go/src go1.13 time/Second. |
| 19 | |
| 20 | // CopyAndWait is a convenience method which doesn't exist in the API, which copies the file and then waits for the copy to complete |
| 21 | func (client Clientscip-go gomod github.com/tombuildsstuff/giovanni . `github.com/tombuildsstuff/giovanni/storage/2018-03-28/file/files`/Client#) CopyAndWaitscip-go gomod github.com/tombuildsstuff/giovanni . `github.com/tombuildsstuff/giovanni/storage/2018-03-28/file/files`/Client#CopyAndWait().(ctx contextscip-go gomod github.com/golang/go/src go1.13 context/.Contextscip-go gomod github.com/golang/go/src go1.13 context/Context#, accountName, shareName, path, fileName string, input CopyInputscip-go gomod github.com/tombuildsstuff/giovanni . `github.com/tombuildsstuff/giovanni/storage/2018-03-28/file/files`/CopyInput#, pollDuration timescip-go gomod github.com/golang/go/src go1.13 time/.Durationscip-go gomod github.com/golang/go/src go1.13 time/Duration#) (result CopyResultscip-go gomod github.com/tombuildsstuff/giovanni . `github.com/tombuildsstuff/giovanni/storage/2018-03-28/file/files`/CopyResult#, err error) { |
| 22 | copy, e := client.Copyscip-go gomod github.com/tombuildsstuff/giovanni . `github.com/tombuildsstuff/giovanni/storage/2018-03-28/file/files`/Client#Copy().(ctx, accountName, shareName, path, fileName, input) |
| 23 | if err != nil { |
| 24 | result.Responsescip-go gomod github.com/tombuildsstuff/giovanni . `github.com/tombuildsstuff/giovanni/storage/2018-03-28/file/files`/CopyResult#Response. = copy.Responsescip-go gomod github.com/tombuildsstuff/giovanni . `github.com/tombuildsstuff/giovanni/storage/2018-03-28/file/files`/CopyResult#Response. |
| 25 | err = fmtscip-go gomod github.com/golang/go/src go1.13 fmt/.Errorfscip-go gomod github.com/golang/go/src go1.13 fmt/Errorf().("Error copying: %s", e) |
| 26 | return |
| 27 | } |
| 28 | |
| 29 | result.CopyIDscip-go gomod github.com/tombuildsstuff/giovanni . `github.com/tombuildsstuff/giovanni/storage/2018-03-28/file/files`/CopyResult#CopyID. = copy.CopyIDscip-go gomod github.com/tombuildsstuff/giovanni . `github.com/tombuildsstuff/giovanni/storage/2018-03-28/file/files`/CopyResult#CopyID. |
| 30 | |
| 31 | // since the API doesn't return a LRO, this is a hack which also polls every 10s, but should be sufficient |
| 32 | for true { |
| 33 | props, e := client.GetPropertiesscip-go gomod github.com/tombuildsstuff/giovanni . `github.com/tombuildsstuff/giovanni/storage/2018-03-28/file/files`/Client#GetProperties().(ctx, accountName, shareName, path, fileName) |
| 34 | if e != nil { |
| 35 | result.Responsescip-go gomod github.com/tombuildsstuff/giovanni . `github.com/tombuildsstuff/giovanni/storage/2018-03-28/file/files`/CopyResult#Response. = copy.Responsescip-go gomod github.com/tombuildsstuff/giovanni . `github.com/tombuildsstuff/giovanni/storage/2018-03-28/file/files`/CopyResult#Response. |
| 36 | err = fmtscip-go gomod github.com/golang/go/src go1.13 fmt/.Errorfscip-go gomod github.com/golang/go/src go1.13 fmt/Errorf().("Error waiting for copy: %s", e) |
| 37 | return |
| 38 | } |
| 39 | |
| 40 | switch stringsscip-go gomod github.com/golang/go/src go1.13 strings/.ToLowerscip-go gomod github.com/golang/go/src go1.13 strings/ToLower().(props.CopyStatusscip-go gomod github.com/tombuildsstuff/giovanni . `github.com/tombuildsstuff/giovanni/storage/2018-03-28/file/files`/GetResult#CopyStatus.) { |
| 41 | case "pending": |
| 42 | timescip-go gomod github.com/golang/go/src go1.13 time/.Sleepscip-go gomod github.com/golang/go/src go1.13 time/Sleep().(pollDuration) |
| 43 | continue |
| 44 | |
| 45 | case "success": |
| 46 | return |
| 47 | |
| 48 | default: |
| 49 | err = fmtscip-go gomod github.com/golang/go/src go1.13 fmt/.Errorfscip-go gomod github.com/golang/go/src go1.13 fmt/Errorf().("Unexpected CopyState %q", e) |
| 50 | return |
| 51 | } |
| 52 | } |
| 53 | |
| 54 | return |
| 55 | } |