I have a program that downloads files with the standard library (receivehttpfile()).While the download is happening, in another thread i am having the file size updated on that file.
Something strange is happening though. Only after large chunks of the file being downloaded, will the size returned by filesize() actually update. But, if i navigate to the folder that the file is being downloaded to in windows explorer and/or refresh if am already there, it will update the size in both explorer AND the size returned by filesize().
I dont have time at the moment to make an example, but i can if needed later on.
Thanks for your time.
file size not updating while downloading file
-
- Always Here
- Posts: 6426
- Joined: Fri Oct 23, 2009 2:33 am
- Location: Wales, UK
- Contact:
Re: file size not updating while downloading file
If you are displaying the value in a StringGadget(), use a TextGadget() instead. After updating the TextGadget(), While WindowEvent() : Wend
IdeasVacuum
If it sounds simple, you have not grasped the complexity.
If it sounds simple, you have not grasped the complexity.
Re: file size not updating while downloading file
I am using a text gadget, and its not an issue with the gadget updating. The problem is that that the filesize() function returns the same thing for about 5-10 seconds at a time while the download is happening in another thread(checked debug output to verify).
The strange part is that if i navigate to the folder where the file is being saved to and hit refresh, it updates the file size on windows explorer AND the return of the filesize function starts showing a newer value.
The strange part is that if i navigate to the folder where the file is being saved to and hit refresh, it updates the file size on windows explorer AND the return of the filesize function starts showing a newer value.
-
- Always Here
- Posts: 6426
- Joined: Fri Oct 23, 2009 2:33 am
- Location: Wales, UK
- Contact:
Re: file size not updating while downloading file
... I think we will need a code snippet that demonstrates the issue. Wouldn't it be better if the filesize() function was in the same thread as the download?
IdeasVacuum
If it sounds simple, you have not grasped the complexity.
If it sounds simple, you have not grasped the complexity.
Re: file size not updating while downloading file
I plan to add a snippet after i get home from work. No, the download is put in a seperate thread so that it doesnt hang the main application window. filesize is being used from the main thread to get a download progress by comparing the current filesize to the final file size.
Re: file size not updating while downloading file
You can use PostEvent() from the thread to indicate progress to the main thread where the update of the gadget occurs.
-
- Enthusiast
- Posts: 137
- Joined: Thu Nov 15, 2012 11:38 pm
- Location: Los Angeles
Re: file size not updating while downloading file
Filesize() is returned at the whim of the OS, no? Windows' own subsystem doesn't report transfers bit-for-bit so I wouldn't rely on that as a live progress marker. I think ReceiveHTTPFile is more of a set-it-and-forget-it implementation as opposed to ReceiveFTPFile which has FTPProgress. Some nice magic using ReceiveNetworkData in TerryHough's example: http://www.purebasic.fr/english/viewtop ... 13&t=50016
Also found this interesting tidbit: "When sending small files, the headers can be a significant part of the amount of actual data transfered." http://daniel.haxx.se/docs/ftp-vs-http.html
Also found this interesting tidbit: "When sending small files, the headers can be a significant part of the amount of actual data transfered." http://daniel.haxx.se/docs/ftp-vs-http.html