diff --git a/share-download-main.go b/share-download-main.go index 7e91a209..828bd965 100644 --- a/share-download-main.go +++ b/share-download-main.go @@ -102,19 +102,20 @@ func doShareDownloadURL(targetURL string, recursive bool, expiry time.Duration) incomplete := false for content := range clnt.List(recursive, incomplete) { if content.Err != nil { - return content.Err.Trace() + return content.Err.Trace(clnt.GetURL().String()) } objectURL := content.Content.URL.String() newClnt, err := url2Client(objectURL) if err != nil { - return err.Trace() + return err.Trace(objectURL) } // Generate share URL. shareURL, err := newClnt.ShareDownload(expiry) if err != nil { - return err.Trace() + // add objectURL and expiry as part of the trace arguments. + return err.Trace(objectURL, "expiry="+expiry.String()) } // Make new entries to shareDB. @@ -146,6 +147,7 @@ func mainShareDownload(ctx *cli.Context) { // Extract arguments. config := mustGetMcConfig() args := ctx.Args() + // if recursive strip off the "..." url := stripRecursiveURL(args.First()) isRecursive := isURLRecursive(args.First()) expiry := shareDefaultExpiry @@ -156,9 +158,7 @@ func mainShareDownload(ctx *cli.Context) { fatalIf(probe.NewError(e), "Unable to parse expire=‘"+expireArg+"’.") } - targetURL := getAliasURL(stripRecursiveURL(url), config.Aliases) // Expand alias. - - // if recursive strip off the "..." - err := doShareDownloadURL(stripRecursiveURL(targetURL), isRecursive, expiry) + targetURL := getAliasURL(url, config.Aliases) // Expand alias. + err := doShareDownloadURL(targetURL, isRecursive, expiry) fatalIf(err.Trace(targetURL), "Unable to share target ‘"+args.First()+"’.") } diff --git a/share-list-main.go b/share-list-main.go index 6387f7c2..faa7f34f 100644 --- a/share-list-main.go +++ b/share-list-main.go @@ -56,21 +56,29 @@ func checkShareListSyntax(ctx *cli.Context) { // doShareList list shared url's. func doShareList(cmd string) *probe.Error { + if cmd != "upload" && cmd != "download" { + return probe.NewError(fmt.Errorf("Unknown argument ‘%s’ passed.", cmd)) + } + + // Fetch defaults. + uploadsFile := getShareUploadsFile() + downloadsFile := getShareDownloadsFile() + // Load previously saved upload-shares. shareDB := newShareDBV1() - switch cmd { - case "upload": - err := shareDB.Load(getShareUploadsFile()) - if err != nil { - return err.Trace(getShareUploadsFile()) + + // if upload - read uploads file. + if cmd == "upload" { + if err := shareDB.Load(uploadsFile); err != nil { + return err.Trace(uploadsFile) } - case "download": - err := shareDB.Load(getShareDownloadsFile()) - if err != nil { - return err.Trace(getShareDownloadsFile()) + } + + // if download - read downloads file. + if cmd == "download" { + if err := shareDB.Load(downloadsFile); err != nil { + return err.Trace(downloadsFile) } - default: - return probe.NewError(fmt.Errorf("Unknown argument ‘%s’ passed.", cmd)) } // Print previously shared entries. diff --git a/share-upload-main.go b/share-upload-main.go index 7b9dc07e..46f662a3 100644 --- a/share-upload-main.go +++ b/share-upload-main.go @@ -162,6 +162,7 @@ func mainShareUpload(ctx *cli.Context) { args := ctx.Args() config := mustGetMcConfig() + // if recursive strip off the "..." url := stripRecursiveURL(args.First()) isRecursive := isURLRecursive(args.First()) expireArg := ctx.String("expire")