Skip to content

Etag support - #742

Merged
fsouza merged 1 commit into
fsouza:mainfrom
DarthSim:feature/etag
Apr 7, 2022
Merged

Etag support#742
fsouza merged 1 commit into
fsouza:mainfrom
DarthSim:feature/etag

Conversation

@DarthSim

@DarthSim DarthSim commented Apr 7, 2022

Copy link
Copy Markdown
Contributor

Hey! Thanks for the project, it's very useful!
This PR adds Etags support. I'm not sure I patched everything I should yet this works for me, so maybe someone would find this useful.

@fsouza fsouza left a comment

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

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

Thanks for contributing, just some nits on how we quote the string!

Comment thread fakestorage/upload.go Outdated
Crc32c: checksum.EncodedCrc32cChecksum(data),
Md5Hash: checksum.EncodedMd5Hash(data),
Md5Hash: md5Hash,
Etag: fmt.Sprintf("\"%s\"", md5Hash),

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

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

nit:

Suggested change
Etag: fmt.Sprintf("\"%s\"", md5Hash),
Etag: fmt.Sprintf("%q", md5Hash),
Comment thread fakestorage/upload.go Outdated
Crc32c: checksum.EncodedCrc32cChecksum(data),
Md5Hash: checksum.EncodedMd5Hash(data),
Md5Hash: md5Hash,
Etag: fmt.Sprintf("\"%s\"", md5Hash),

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

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

Suggested change
Etag: fmt.Sprintf("\"%s\"", md5Hash),
Etag: fmt.Sprintf("%q", md5Hash),
Comment thread fakestorage/upload.go Outdated
Crc32c: checksum.EncodedCrc32cChecksum(data),
Md5Hash: checksum.EncodedMd5Hash(data),
Md5Hash: md5Hash,
Etag: fmt.Sprintf("\"%s\"", md5Hash),

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

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

Suggested change
Etag: fmt.Sprintf("\"%s\"", md5Hash),
Etag: fmt.Sprintf("%q", md5Hash),
Comment thread fakestorage/upload.go Outdated
Crc32c: checksum.EncodedCrc32cChecksum(content),
Md5Hash: checksum.EncodedMd5Hash(content),
Md5Hash: md5Hash,
Etag: fmt.Sprintf("\"%s\"", md5Hash),

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

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

Suggested change
Etag: fmt.Sprintf("\"%s\"", md5Hash),
Etag: fmt.Sprintf("%q", md5Hash),
Comment thread fakestorage/upload.go Outdated
obj.Content = append(obj.Content, content...)
obj.Crc32c = checksum.EncodedCrc32cChecksum(obj.Content)
obj.Md5Hash = checksum.EncodedMd5Hash(obj.Content)
obj.Etag = fmt.Sprintf("\"%s\"", obj.Md5Hash)

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

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

Suggested change
obj.Etag = fmt.Sprintf("\"%s\"", obj.Md5Hash)
obj.Etag = fmt.Sprintf("%q", obj.Md5Hash)
@DarthSim

DarthSim commented Apr 7, 2022

Copy link
Copy Markdown
Contributor Author

Yep, you're right, totally forgot about %q

@fsouza fsouza left a comment

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

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

Thank you!

@fsouza
fsouza merged commit d717316 into fsouza:main Apr 7, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

2 participants