mirror of
https://gitlab.com/freepascal.org/fpc/source.git
synced 2025-06-05 14:58:28 +02:00
* report URL in download failure
* ignore errors in initial download * fixed crash with selecting mirror without doing an update git-svn-id: trunk@10076 -
This commit is contained in:
parent
c80c97739c
commit
ef9177ccc4
@ -275,8 +275,18 @@ begin
|
||||
LoadCompilerDefaults;
|
||||
|
||||
// Load local repository, update first if this is a new installation
|
||||
// errors will only be reported as warning. The user can be bootstrapping
|
||||
// and do an update later
|
||||
if not FileExists(GlobalOptions.LocalPackagesFile) then
|
||||
pkghandler.ExecuteAction(nil,'update');
|
||||
begin
|
||||
try
|
||||
pkghandler.ExecuteAction(nil,'update');
|
||||
except
|
||||
on E: Exception do
|
||||
Log(vlWarning,E.Message);
|
||||
end;
|
||||
end;
|
||||
LoadLocalMirrors;
|
||||
LoadLocalRepository;
|
||||
LoadFPMakeLocalStatus;
|
||||
// We only need to reload the status when we use a different
|
||||
|
@ -410,7 +410,9 @@ end;
|
||||
|
||||
|
||||
initialization
|
||||
{$ifndef VER2_2}
|
||||
OnGetVendorName:=@FPPkgGetVendorName;
|
||||
{$endif}
|
||||
OnGetApplicationName:=@FPPkgGetApplicationName;
|
||||
|
||||
end.
|
||||
|
@ -6,6 +6,7 @@ interface
|
||||
|
||||
uses
|
||||
SysUtils, Classes,
|
||||
uriparser,
|
||||
lnet, lftp, lhttp, pkgdownload,pkgoptions, fprepos;
|
||||
|
||||
Type
|
||||
@ -18,6 +19,7 @@ Type
|
||||
FFTP: TLFTPClient;
|
||||
FHTTP: TLHTTPClient;
|
||||
FOutStream: TStream;
|
||||
URI: TURI;
|
||||
protected
|
||||
// callbacks
|
||||
function OnHttpClientInput(ASocket: TLHTTPClientSocket; ABuffer: pchar;
|
||||
@ -39,7 +41,6 @@ Type
|
||||
implementation
|
||||
|
||||
uses
|
||||
uriparser,
|
||||
pkgglobals,
|
||||
pkgmessages;
|
||||
|
||||
@ -95,13 +96,11 @@ procedure TLNetDownloader.OnFTPFailure(aSocket: TLSocket;
|
||||
const aStatus: TLFTPStatus);
|
||||
begin
|
||||
FFTP.Disconnect;
|
||||
Error(SErrDownloadFailed,['FTP','']);
|
||||
Error(SErrDownloadFailed,['FTP',EncodeURI(URI),'']);
|
||||
FQuit:=True;
|
||||
end;
|
||||
|
||||
procedure TLNetDownloader.FTPDownload(const URL: String; Dest: TStream);
|
||||
var
|
||||
URI: TURI;
|
||||
begin
|
||||
FOutStream:=Dest;
|
||||
Try
|
||||
@ -128,8 +127,6 @@ begin
|
||||
end;
|
||||
|
||||
procedure TLNetDownloader.HTTPDownload(const URL: String; Dest: TStream);
|
||||
var
|
||||
URI: TURI;
|
||||
begin
|
||||
FOutStream:=Dest;
|
||||
Try
|
||||
@ -149,7 +146,7 @@ begin
|
||||
while not FQuit do
|
||||
FHTTP.CallAction;
|
||||
if FHTTP.Response.Status<>HSOK then
|
||||
Error(SErrDownloadFailed,['HTTP',FHTTP.Response.Reason]);
|
||||
Error(SErrDownloadFailed,['HTTP',EncodeURI(URI),FHTTP.Response.Reason]);
|
||||
Finally
|
||||
FOutStream:=nil; // to be sure
|
||||
end;
|
||||
|
@ -32,7 +32,7 @@ Resourcestring
|
||||
SErrBackupFailed = 'Backup of file "%s" to file "%s" failed.';
|
||||
SErrUnknownProtocol = 'Unknown download protocol: "%s"';
|
||||
SErrNoSuchFile = 'File "%s" does not exist.';
|
||||
SErrDownloadFailed = '%s Download failed: %s';
|
||||
SErrDownloadFailed = '%s Download of "%s" failed: %s';
|
||||
SErrInvalidLogLevels = 'Invalid verbosity string: "%s"';
|
||||
SErrInvalidCommand = 'Invalid command: %s';
|
||||
SErrChangeDirFailed = 'Could not change directory to "%s"';
|
||||
|
@ -82,26 +82,30 @@ var
|
||||
M : TFPMirror;
|
||||
begin
|
||||
Result:='';
|
||||
// Create array for selection
|
||||
BucketCnt:=0;
|
||||
for i:=0 to CurrentMirrors.Count-1 do
|
||||
inc(BucketCnt,CurrentMirrors[i].Weight);
|
||||
// Select random entry
|
||||
Bucket:=Random(BucketCnt);
|
||||
M:=nil;
|
||||
for i:=0 to CurrentMirrors.Count-1 do
|
||||
begin
|
||||
for j:=0 to CurrentMirrors[i].Weight-1 do
|
||||
begin
|
||||
if Bucket=0 then
|
||||
begin
|
||||
M:=CurrentMirrors[i];
|
||||
break;
|
||||
end;
|
||||
Dec(Bucket);
|
||||
end;
|
||||
if assigned(M) then
|
||||
break;
|
||||
if assigned(CurrentMirrors) then
|
||||
begin
|
||||
// Create array for selection
|
||||
BucketCnt:=0;
|
||||
for i:=0 to CurrentMirrors.Count-1 do
|
||||
inc(BucketCnt,CurrentMirrors[i].Weight);
|
||||
// Select random entry
|
||||
Bucket:=Random(BucketCnt);
|
||||
M:=nil;
|
||||
for i:=0 to CurrentMirrors.Count-1 do
|
||||
begin
|
||||
for j:=0 to CurrentMirrors[i].Weight-1 do
|
||||
begin
|
||||
if Bucket=0 then
|
||||
begin
|
||||
M:=CurrentMirrors[i];
|
||||
break;
|
||||
end;
|
||||
Dec(Bucket);
|
||||
end;
|
||||
if assigned(M) then
|
||||
break;
|
||||
end;
|
||||
end;
|
||||
if assigned(M) then
|
||||
begin
|
||||
@ -114,8 +118,6 @@ end;
|
||||
|
||||
|
||||
function GetRemoteRepositoryURL(const AFileName:string):string;
|
||||
var
|
||||
i : integer;
|
||||
begin
|
||||
if CurrentRemoteRepositoryURL='' then
|
||||
begin
|
||||
|
@ -53,7 +53,7 @@ begin
|
||||
Dest.WriteBuffer(Buffer,Count);
|
||||
end;
|
||||
If (ExitStatus<>0) then
|
||||
Error(SErrDownloadFailed,['WGET',Format('exit status %d',[ExitStatus])]);
|
||||
Error(SErrDownloadFailed,['WGET',URL,Format('exit status %d',[ExitStatus])]);
|
||||
finally
|
||||
Free;
|
||||
end;
|
||||
|
Loading…
Reference in New Issue
Block a user