From: <ah...@us...> - 2013-05-25 16:01:34
|
Revision: 13529 http://jvcl.svn.sourceforge.net/jvcl/?rev=13529&view=rev Author: ahuser Date: 2013-05-25 16:01:27 +0000 (Sat, 25 May 2013) Log Message: ----------- Mantis 5923: TJvCustomURLGrabber can save a file of 0 size if Internet connection not available. Modified Paths: -------------- trunk/jvcl/run/JvUrlListGrabber.pas Modified: trunk/jvcl/run/JvUrlListGrabber.pas =================================================================== --- trunk/jvcl/run/JvUrlListGrabber.pas 2013-05-25 15:53:17 UTC (rev 13528) +++ trunk/jvcl/run/JvUrlListGrabber.pas 2013-05-25 16:01:27 UTC (rev 13529) @@ -385,6 +385,8 @@ FSize: Int64; // What has been read so far FBytesRead: Int64; + // True if data has been read + FGrabbingStarted: Boolean; protected // Event callers procedure DoError(ErrorMsg: string); @@ -976,6 +978,10 @@ procedure TJvCustomUrlGrabber.DoEnded; begin + // Don't create empty file/stream if we didn't start grabbing + if not FGrabbingStarted Then + Exit; + Stream.Position := 0; if FOutputMode = omStream then begin @@ -1238,6 +1244,7 @@ begin NameThread(ThreadName); SetGrabberStatus(gsStopped); + FGrabber.FGrabbingStarted := False; FGrabber.Stream := nil; try Grab; @@ -1252,10 +1259,11 @@ end; end; -procedure TJvCustomUrlGrabberThread.SetGrabberStatus( - Status: TJvGrabberStatus); +procedure TJvCustomUrlGrabberThread.SetGrabberStatus(Status: TJvGrabberStatus); begin FGrabber.FStatus := Status; + if Status = gsGrabbing then + FGrabber.FGrabbingStarted := True; end; procedure TJvCustomUrlGrabberThread.UpdateGrabberProgress; This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |