Skip to content
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

Fix/limit thumbnail size #678

Merged
merged 10 commits into from
May 13, 2022
Merged

Fix/limit thumbnail size #678

merged 10 commits into from
May 13, 2022

Conversation

lpoli
Copy link
Contributor

@lpoli lpoli commented May 11, 2022

Changes

Delete object function has been optimized by removal redundant of logic and addition of goroutine for disk operations.

Fixes

Thumbnail file size is limited to 1MB

@codecov-commenter
Copy link

codecov-commenter commented May 11, 2022

Codecov Report

Merging #678 (a6a7da1) into staging (c666d22) will decrease coverage by 0.06%.
The diff coverage is 4.25%.

@@             Coverage Diff             @@
##           staging     #678      +/-   ##
===========================================
- Coverage    19.70%   19.64%   -0.07%     
===========================================
  Files           66       66              
  Lines         7530     7559      +29     
===========================================
+ Hits          1484     1485       +1     
- Misses        5819     5846      +27     
- Partials       227      228       +1     
Flag Coverage Δ
Unit-Tests 19.64% <4.25%> (-0.07%) ⬇️

Flags with carried forward coverage won't be shown. Click here to find out more.

Impacted Files Coverage Δ
...ain.net/blobbercore/allocation/deletefilechange.go 0.00% <0.00%> (ø)
...ain.net/blobbercore/handler/file_command_update.go 0.00% <0.00%> (ø)
code/go/0chain.net/blobbercore/reference/object.go 0.00% <0.00%> (ø)
...ain.net/blobbercore/handler/file_command_upload.go 43.75% <44.44%> (-1.18%) ⬇️

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update c666d22...a6a7da1. Read the comment docs.

@lpoli lpoli requested a review from cnlangzi May 12, 2022 04:37
@lpoli lpoli requested a review from peterlimg May 13, 2022 03:54
wg.Done()
}()

if count == 0 {
Copy link
Member

Choose a reason for hiding this comment

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

We can do this count checking out of the gorountine, so if it's not 0, we don't need to start the goroutine.

if thumbHeader != nil {
if thumbHeader.Size > MaxThumbnailSize {
return common.NewError("max_thumbnail_size",
fmt.Sprintf("Thumbnail size %d should not be greater than %d", thumbHeader.Size, MaxThumbnailSize))
Copy link
Member

Choose a reason for hiding this comment

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

We'd better not capitalize error messages, as they are usually printed following other context.

for _, subDir := range subDirs {
var found bool
for _, ref := range dirRef.Children {
if ref.Name == subDir && ref.Type == DIRECTORY {
Copy link
Member

Choose a reason for hiding this comment

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

Perhaps we should break immediately if the dirRef.Children do not have the subDir, basically this checking all start from the root path, if any level of the path do not exist in the corresponding dirRef, there must be something wrong.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

It does break with return statement.

Copy link
Member

@peterlimg peterlimg left a comment

Choose a reason for hiding this comment

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

lgtm

@lpoli lpoli merged commit 6652c59 into staging May 13, 2022
@lpoli lpoli deleted the fix/limit-thumbnail-size branch May 13, 2022 09:11
Copy link
Contributor

@cnlangzi cnlangzi left a comment

Choose a reason for hiding this comment

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

@peterlimg @lpoli , this PR breaks multiple things

  • breaks 204 status for partial delete
  • it is incorrect to delete thumbnail if hash is not empty. Because hash always has value even it is empty.

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.

None yet

4 participants