Skip to content

Fix time calculation bug in sharing feature #121

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 1 commit into from
Jul 17, 2025

Conversation

parzel
Copy link
Contributor

@parzel parzel commented Jul 17, 2025

Issue

There was an issue on how seconds and time.Seconds were cast when creating shared links, leading to them being immediately expired.

Description

I modified the casts to work properly.

@patrickhener
Copy link
Owner

Can you tell me how exactly you tested. Because if I use for example:

goshs -b test:test

in a folder, then share a file

image

this will make that file accessible for 60 minutes as desired. It is not expired right away.

@patrickhener
Copy link
Owner

But as your example works as well as mine and the code looks cleaner, I'll merge your variant. Thanks for contributing.

@patrickhener patrickhener merged commit 8d1ebfd into patrickhener:main Jul 17, 2025
3 checks passed
@parzel
Copy link
Contributor Author

parzel commented Jul 17, 2025

That is strange! I just verified it again and run into the same issue on the previous branch. Maybe there has been a change in go? I am running go1.24.4.

@patrickhener
Copy link
Owner

I am on 1.24.2

@parzel
Copy link
Contributor Author

parzel commented Jul 17, 2025

I think I was able to single out the issue. It only exists on my side when using the x86 version. Maybe you tested with x64?

@patrickhener
Copy link
Owner

Yes I tested x64. But the PR does resolve it on x86?

@parzel
Copy link
Contributor Author

parzel commented Jul 17, 2025

Ah I suppose got it. I think its an integer overflow because int(time.Second)* seconds can overflow the integer range. If you try to compile something like fmt.Printf("value: %v\n", time.Duration(int(time.Second)*3600)) you will get an overflow error from the compiler. As the second value is not known to it in the case of your program, it does not complain. The fix therefore helps on x86.

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.

2 participants