Sign in to follow this  
Followers 0
Clay

INetGetSize

3 posts in this topic

I think I may have found a bug with the InetGetSize function ..... I Think.

I use INetGetSize in one of my scripts that downloads files from one of my web servers.... I use the script in the follow fashion

SNIPPET

Inetget($pkgGetSource, @ScriptDir & "\" & $fileame, 0, 1)
$FileSize = InetGetSize($pkgGetSource)
ProgressOn("DevCentral File Download","Increments every second")
While @InetGetActive
     $Percentage = @InetGetBytesRead * 100 / $pkgGetSource
      ProgressSet($Percentage,"Downloaded " & @InetGetBytesRead & " of " & $FileSize & "  
      bytes","Downloading " & $fileame)
      Sleep(250)
Wend
ProgressOff()

What happens is that both Inetget and InetGetSize open connection to the file.... but once the file is downloaded only the connection opened by Inetget closes.

I think this may be a bug because the help file does not indicate that a connection need to be closed when using InetGetSize. This in turn cases complications when someone else tries to download the file... because it is being held open.

Any thoughts..... am I just using this thing wrong or does this qualify as an issue?

Share this post


Link to post
Share on other sites



"background" Parameter

By default the function waits until the download has finished before returning. Sometimes with large downloads this is not always wanted. If the background parameter is set to 1 the function returns immediately and the download continues in the background. When in this mode two macros are used to keep track:

@InetGetActive = 1 while downloading, or 0 when finished.

@InetGetBytesRead = the number of bytes downloaded, or -1 if there has been an error.

Note, only one download can be active at once, if you call the function again before a download is complete it will fail.

I am sure this includes InetGetSize()

For a simple answer, just reverse them...

$FileSize = InetGetSize($pkgGetSource)
Inetget($pkgGetSource, @ScriptDir & "\" & $fileame, 0, 1)
ProgressOn("DevCentral File Download","Increments every second")
While @InetGetActive
     $Percentage = @InetGetBytesRead * 100 / $pkgGetSource
      ProgressSet($Percentage,"Downloaded " & @InetGetBytesRead & " of " & $FileSize & "bytes","Downloading " & $fileame)
      Sleep(250)
Wend
ProgressOff()

8)


NEWHeader1.png

Share this post


Link to post
Share on other sites

Although I did try reversing InetGet and InetGetSize initially... you are right Valuater, and it makes alot of sense. I must have not saved my changes when tested after initially reversing the functions. Also, I apologize for the horrible grammer in my initial post... and any bad grammer in this reply.

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!


Register a new account

Sign in

Already have an account? Sign in here.


Sign In Now
Sign in to follow this  
Followers 0