Skip to content

s3: implement link sharing - #4280

Merged
ncw merged 2 commits into
rclone:masterfrom
Shareed2k:master
Jun 5, 2020
Merged

ncw merged 2 commits into
rclone:masterfrom
Shareed2k:master

Conversation

@Shareed2k

@Shareed2k Shareed2k commented May 26, 2020 •

Copy link
Copy Markdown
Contributor

What is the purpose of this change?

Add link sharing to S3

Was the change discussed in an issue or in the forum before?

#2178

Checklist

  • I have read the contribution guidelines.
  • I have added tests for all changes in this PR if appropriate.
  • I have added documentation for the changes if appropriate.
  • All commit messages are in house style.
  • I'm done, this Pull Request is ready for review :-)

@ncw

ncw commented May 27, 2020

Copy link
Copy Markdown
Member

I think this code looks fine! I will give a detailed review when I've finished getting the 1.52 release out so apologies for the delay...

@ncw ncw left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nice feature - thank you :-)

See inline for comments.

Comment thread backend/s3/s3.go Resolved
Comment thread backend/s3/s3.go Resolved
@Shareed2k
Shareed2k requested a review from ncw May 31, 2020 21:34

@ncw ncw left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

See comments inline!

You need to fix up the tests too - that is why the build is breaking.

Comment thread cmd/link/link.go Outdated

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This should default to very large to be compatible with previous rclone versions - say 100 years!

Also using a type of fs.Duration here will give the user more options when configuring it including days, weeks absolute times etc! You'll need to cast it back to time.Duration for the call.

expire = fs.Duration(time.Hour * 24 * 365 * 100)

Comment thread cmd/link/link.go Outdated

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This needs a "Note: not all backends support this flag - if the backend doesn't support it then the link returned won't expire."

Comment thread cmd/link/link.go Outdated

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This needs a similar note: Not all backends support --unlink - those that don't will just ignore it.

Comment thread fs/rc/cache.go Outdated

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'd just call this in rcPublicLink

unlink, _ = in.GetBool("unlink")

You don't want to give an error if the user doesn't pass the parameter you want it to default to false.

Likewise the expire parameter - missing should mean very large.

Comment thread fs/rc/cache.go Outdated

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can you move this to fs/rc/params.go and call it GetDuration and change it so it only reads a duration. This could do with a test too in fs/rc/params_test.go

@Shareed2k
Shareed2k requested a review from ncw June 2, 2020 05:42

@ncw ncw left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think that looks great now - thank you :-)

Can you squash it into two commits (in this order)

  1. Add extra fields to PublicLink interface and consequent changes
  2. The changes to the s3 backend "s3: implement link sharing"

Then I'll merge it - thank you :-)

@Shareed2k
Shareed2k requested a review from ncw June 4, 2020 21:05
Shareed2k added 2 commits June 5, 2020 14:26
This adds expire and unlink fields to the PublicLink interface.

This fixes up the affected backends and removes unlink parameters
where they are present.

@ncw ncw left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

That looks great thanks!

I've just given the docs and the commit messages a bit of a tweak then I'll merge.

Thank you very much - great feature :-)

@ncw
ncw merged commit c052179 into rclone:master Jun 5, 2020
@Zirro

Zirro commented Jun 9, 2020

Copy link
Copy Markdown

...if the backend doesn't support it then the link returned won't expire.

Ignoring these options silently seems a bit risky. Wouldn't it be more appropriate to error out for backends without support (in addition to if a supporting backend responds with an error)?

@ncw

ncw commented Jun 10, 2020

Copy link
Copy Markdown
Member

Ignoring these options silently seems a bit risky. Wouldn't it be more appropriate to error out for backends without support (in addition to if a supporting backend responds with an error)?

I agree, but it is a lot more work to do that. It would require error checking in all the backends which implement PublicLink. Might be a good project if you fancied having a go @Zirro ?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants