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 unable to download item twice #1958

Merged
merged 1 commit into from
Mar 1, 2024
Merged

Fix unable to download item twice #1958

merged 1 commit into from
Mar 1, 2024

Conversation

ike08
Copy link
Contributor

@ike08 ike08 commented Feb 24, 2024

Summary

Partial fix for #1939

When doing the same in an unencrypted (no e2ee) chat there is no Downloading… message at all but the file is downloaded.

Download a file twice with /url save, the second download will not print download progress to the window.

The cause is HTTPDownload's silent variable is not initialized; so, silent points to a second-hand stack memory address with old data. silent references data, so the if statement will fail in src/tools/http_download.c:206 and download progress will not print to the window.

The fix is to initialize silent in both encrypted and unencrypted file download scenarios.

Testing

Valgrind: Yes

  • /url save without OMEMO
    SUCCESS: Try three times with the same URL and download status will display every time.

  • /url save with OMEMO
    SUCCESS: Try three times with the same URL and download status will display every time.

  • /plugins install [https://raw.githubusercontent.com/profanity-im/profanity-plugins/master/stable/sounds.py](https://raw.githubusercontent.com/profanity-im/profanity-plugins/master/stable/sounds.py%60)
    SUCCESS: Try once and download progress is hidden.

@jubalh jubalh self-requested a review February 25, 2024 06:29
@jubalh jubalh added this to the next milestone Feb 25, 2024
@ike08
Copy link
Contributor Author

ike08 commented Feb 27, 2024

Partially related to #1939

When doing the same in an unencrypted (no e2ee) chat there is no Downloading… message at all but the file is downloaded.

@jubalh
Copy link
Member

jubalh commented Feb 28, 2024

Thanks for your PR! Could you mention 1939 in the commit message as well? Otherwise good to merge :)

## Summary

Partial fix for #1939  

> When doing the same in an unencrypted (no e2ee) chat there is no Downloading… message at all but the file is downloaded.  

Download a file twice with `/url save`, the second download will not print download progress to the window.  

The cause is `HTTPDownload`'s `silent` variable is not initialized; so, `silent` points to a second-hand stack memory address with old data. `silent` references data, so the `if` statement will fail in **src/tools/http_download.c:206** and download progress will not print to the window.  

The fix is to initialize `silent` in both encrypted and unencrypted file download scenarios.  

## Testing

Valgrind: Yes  

- `/url save` without OMEMO  
  **SUCCESS**: Try three times with the same URL and download status will display every time.  

- `/url save` with OMEMO  
  **SUCCESS**: Try three times with the same URL and download status will display every time.  

- `/plugins install https://raw.githubusercontent.com/profanity-im/profanity-plugins/master/stable/sounds.py`  
  **SUCCESS**: Try once and download progress is hidden.
@jubalh jubalh merged commit e5eb0f4 into profanity-im:master Mar 1, 2024
6 checks passed
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.

None yet

2 participants