-
Notifications
You must be signed in to change notification settings - Fork 100
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Implementing sharelink feature requested in #77 #89
base: master
Are you sure you want to change the base?
Conversation
cmd/share-createlink.go
Outdated
@@ -0,0 +1,147 @@ | |||
// Copyright © 2017 Dropbox, Inc. | |||
// Author: Daniel Porteous |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
For consistency, can you omit this line? git blame
can always reveal authors :)
cmd/share-createlink.go
Outdated
"github.com/spf13/cobra" | ||
) | ||
|
||
/** |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please use //
to start comments. While go does support C style block comments, //
is the norm and Javadoc-style comments are rare. More at https://golang.org/doc/effective_go.html#commentary
cmd/share-createlink.go
Outdated
// Confirm that the file exists. | ||
exists, err := exists(path) | ||
if !exists || err != nil { | ||
print("The file / folder specified does not exist.\n") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Print the path here as well so users have context
cmd/share-createlink.go
Outdated
return | ||
} | ||
|
||
// print("File / folder does not yet have a sharelink, creating one...\n") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Delete?
cmd/share-createlink.go
Outdated
fmt.Printf("Usage: %s share getlink [file / folder path]\n", os.Args[0]) | ||
} | ||
|
||
/* |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Same for comments here and elsewhere, start with //
cmd/share-createlink.go
Outdated
** Try to get an existing share link for a file / folder. | ||
** It returns true if the file / folder had a link. Otherwise it returns false. | ||
*/ | ||
func getExistingLink(dbx sharing.Client, path string) bool { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The name of this function is counter-intuitive, as it doesn't actually return the existing link. Perhaps checkExistingLink
?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It doesn't just check the existing link though, it also returns it if it exists. I think checkExistingLinkAndReturnIfExists
would be a bit wordy 😉. I can change it regardless if you want.
cmd/share-createlink.go
Outdated
** CreateSharedLinkWithSettings doesn't allow pending uploads, | ||
** so we use the partially deprecated CreateSharedLink. | ||
*/ | ||
func getNewLink(dbx sharing.Client, path string) bool { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks like you are using bool to handle errors. Why not return error
instead?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Sounds like a good idea, I'll try that.
cmd/share-createlink.go
Outdated
// Get the sharelink even if the file isn't fully uploaded yet. | ||
arg.PendingUpload = new(sharing.PendingUploadMode) | ||
// Determine whether the target is a file or folder. | ||
fi, err := os.Stat(path) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You can do this check before creating arg
cmd/share-createlink.go
Outdated
} | ||
|
||
/* Return the path of the Dropbox folder. */ | ||
func getDropboxFolder() string { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This whole function is super hacky and likely not cross-platform. Let me think if there's a better way.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Awesome, thanks. I'll address the other issues now and we can come back to this when you have a solution. There should be a function somewhere that returns where the Dropbox folder is, the information has to be held somewhere.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Given the complexity around obtaining the "canonical" Dropbox folder, for all scenarios (e.g. paid users, paired accounts, custom directories) and for all platforms, I'd prefer if we solve this via documentation and help, and being explicit. For instance, we can ask users to just supply the path instead of trying to prefix things ourselves. WDYT?
I addressed all of the issues except those related to |
Any ETA on when this feature can be live? |
@coatless Just waiting on the go ahead from @diwakergupta, as well as perhaps a cleaner way to do the functionality provided by |
@diwakergupta Think you could have another look at this? |
@banool @diwakergupta it would be great to see headway on this feature as the root@remote:~# ~/dropbox.py status
You're using an old version of Dropbox. Please update within the next 4 days to continue using Dropbox.
https://www.dropbox.com/downloading?from_client=True
Up to date |
Sorry folks, will take a look right away! |
@diwakergupta Any update on this PR? I'd love to use this command. I installed
|
@banool is there a way to install your version to test it? |
Bumping this, I would love to see this feature incorporated into the main branch. |
I would love to have this PR merged too! |
@diwakergupta any update on if this will get merged? It would be really nice to have. |
I know this is super old and seems to not actually be maintained any more, but when I try to
|
Sadly, I think this software is official dead. I wouldn't push forward more on this as it literally was a year and then some. Consider looking into Dropbox alternatives. |
Unfortunately yes, I haven't looked into this PR for a long time. I don't intend to pick up the work again either since, as @coatless says, this appears to be entirely dead. Dropbox seems to be more interested in the designer / creative space than the technical space these days, so I don't expect to see any further development on this either. Given the recent price increase and worsening features relative to competitors, might be time to look elsewhere. |
Yeah, I figured that'd be the case. Thanks for the responses. If anyone finds this in the future, here's a Groovy script that I wrote to accomplish what I needed. https://gitlab.com/snippets/1915960 |
I wanted to give it a look and I manage to make it work! I rebased the PR (otherwise I had a segmentation fault).
As you can see, Regarding the output I would remove the file name in order to make the result "pipable":
(for non MacOS user, |
To anybody interested in that option: |
|
I'm unsubscribing from this, please tag me if you need me if the maintainers ever return. Thanks! |
@banool If you want to get notified, stay subscribed because I don't think I will remember to ping you when it merged (there is not so much activity here anyway). @biounix I just tried tbx for the first time after having it under my watched repository since you mentioned it. I opened a question here about it. |
This is in response to #77.
Following the current command structure for
dbxcli
, the new command can be found atdbxcli share getlink
.If the file / folder already has a sharelink, that link is retrieved and printed. This follows the pre-existing printing format from the sharing functions. If it doesn't have a sharelink, the link is created and printed.
There is also support for getting links for files that haven't fully uploaded yet. I wanted to functionality to be precisely like if you right click on a file and use Copy Dropbox Link. The side effect of this is I had to use the partially deprecated
create_shared_link
endpoint.This is the first Go I've ever coded so I'm of course open to revisions.