10000 Fix ceiling size calculation by svavassori · Pull Request #46 · jiro4989/build-deb-action · GitHub
[go: up one dir, main page]
More Web Proxy on the site http://driver.im/
Skip to content

8000 Fix ceiling size calculation #46

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

Merged
merged 3 commits into from
May 22, 2023
Merged

Fix ceiling size calculation #46

merged 3 commits into from
May 22, 2023

Conversation

svavassori
Copy link
Contributor
@svavassori svavassori commented May 18, 2023

With the current implementation, if the size is a multiple of kB, it will add 1.

$ awk -v size="1023" 'BEGIN {print (size/1024)+1}' | awk '{print int($0)}'
1
$ awk -v size="1024" 'BEGIN {print (size/1024)+1}' | awk '{print int($0)}'
2
$ awk -v size="1025" 'BEGIN {print (size/1024)+1}' | awk '{print int($0)}'
2

This PR fixes it calculating the correct values:

$ echo $(( (1023 + 1024 - 1)/1024 ))
1
$ echo $(( (1024 + 1024 - 1)/1024 ))
1
$ echo $(( (1025 + 1024 - 1)/1024 ))
2

source: https://stackoverflow.com/questions/2394988/get-ceiling-integer-from-number-in-linux-bash

@jiro4989
Copy link
Owner

Thank you. I will check in a few days.

@svavassori svavassori requested a review from jiro4989 May 21, 2023 13:30
@jiro4989
Copy link
Owner

LGTM👍

LGTM

@jiro4989 jiro4989 merged commit d38d2ef into jiro4989:master May 22, 2023
@github-actions
Copy link

🚀 [bumpr] Bumped! New version:v2.8.1 Changes:v2.8.0...v2.8.1

@svavassori svavassori deleted the fix/correct-size-calculation branch May 22, 2023 13:10
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants
0