updated error handler
This commit is contained in:
parent
befb651268
commit
7144f5c794
Binary file not shown.
@ -11,6 +11,7 @@ type TOS = (osWindows, osLinux32, osLinux64);
|
|||||||
procedure AddStatus(Text: String; Color: TColor; ShowTime: Boolean = True);
|
procedure AddStatus(Text: String; Color: TColor; ShowTime: Boolean = True);
|
||||||
procedure AddDone(Additional: String = '');
|
procedure AddDone(Additional: String = '');
|
||||||
procedure AddSkipped;
|
procedure AddSkipped;
|
||||||
|
procedure AddNotFound;
|
||||||
function DelDir(Dir: string): Boolean;
|
function DelDir(Dir: string): Boolean;
|
||||||
procedure MakeDir(Dir: String);
|
procedure MakeDir(Dir: String);
|
||||||
procedure DownloadFile(eFile: String; eDestination: String);
|
procedure DownloadFile(eFile: String; eDestination: String);
|
||||||
@ -80,7 +81,7 @@ end;
|
|||||||
procedure AddSkipped;
|
procedure AddSkipped;
|
||||||
begin
|
begin
|
||||||
frmMain.rtfDetails.SelStart := Length(frmMain.rtfDetails.Text);
|
frmMain.rtfDetails.SelStart := Length(frmMain.rtfDetails.Text);
|
||||||
frmMain.rtfDetails.SelAttributes.Color := $0000ECFF;
|
frmMain.rtfDetails.SelAttributes.Color := $004080FF; // orange
|
||||||
frmMain.rtfDetails.SelText := ' Skipped.';
|
frmMain.rtfDetails.SelText := ' Skipped.';
|
||||||
frmMain.rtfDetails.Perform(WM_VSCROLL, SB_BOTTOM, 0);
|
frmMain.rtfDetails.Perform(WM_VSCROLL, SB_BOTTOM, 0);
|
||||||
|
|
||||||
@ -88,6 +89,17 @@ begin
|
|||||||
Application.ProcessMessages;
|
Application.ProcessMessages;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
|
procedure AddNotFound;
|
||||||
|
begin
|
||||||
|
frmMain.rtfDetails.SelStart := Length(frmMain.rtfDetails.Text);
|
||||||
|
frmMain.rtfDetails.SelAttributes.Color := clRed;
|
||||||
|
frmMain.rtfDetails.SelText := ' Not found.';
|
||||||
|
frmMain.rtfDetails.Perform(WM_VSCROLL, SB_BOTTOM, 0);
|
||||||
|
|
||||||
|
frmMain.Repaint;
|
||||||
|
Application.ProcessMessages;
|
||||||
|
end;
|
||||||
|
|
||||||
function DelDir(Dir: string): Boolean;
|
function DelDir(Dir: string): Boolean;
|
||||||
var Fos: TSHFileOpStruct;
|
var Fos: TSHFileOpStruct;
|
||||||
begin
|
begin
|
||||||
@ -110,26 +122,30 @@ begin
|
|||||||
end;
|
end;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
procedure FileCopy(Source, Destination: String; CopyConfig: Boolean);
|
procedure FileCopy(Source, Destination: String; CopyConfig: Boolean; AddStatus: Boolean = True);
|
||||||
begin
|
begin
|
||||||
if (not CopyConfig) and (Pos('config', Source) <> 0) then
|
if (not CopyConfig) and (Pos('config', Source) <> 0) then begin
|
||||||
exit;
|
if AddStatus then
|
||||||
if not FileExists(Source) then
|
AddSkipped;
|
||||||
exit;
|
exit;
|
||||||
|
end;
|
||||||
|
|
||||||
if FileExists(Destination) then begin
|
if not FileExists(Source) then begin
|
||||||
try
|
if AddStatus then
|
||||||
DeleteFile(PChar(Destination));
|
AddNotFound;
|
||||||
except
|
exit;
|
||||||
Application.ProcessMessages;
|
|
||||||
end;
|
|
||||||
end;
|
end;
|
||||||
|
|
||||||
try
|
try
|
||||||
|
if FileExists(Destination) then
|
||||||
|
DeleteFile(PChar(Destination));
|
||||||
CopyFile(PChar(Source), PChar(Destination), False);
|
CopyFile(PChar(Source), PChar(Destination), False);
|
||||||
except
|
except
|
||||||
Application.ProcessMessages;
|
Application.ProcessMessages;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
|
if AddStatus then
|
||||||
|
AddDone;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
procedure DownloadFile(eFile: String; eDestination: String);
|
procedure DownloadFile(eFile: String; eDestination: String);
|
||||||
@ -350,9 +366,11 @@ begin
|
|||||||
FileSetAttr(ePath + 'liblist.gam', 0);
|
FileSetAttr(ePath + 'liblist.gam', 0);
|
||||||
eStr.SaveToFile(ePath + 'liblist.gam');
|
eStr.SaveToFile(ePath + 'liblist.gam');
|
||||||
FileSetAttr(ePath + 'liblist.gam', faReadOnly); // important for listen servers
|
FileSetAttr(ePath + 'liblist.gam', faReadOnly); // important for listen servers
|
||||||
end;
|
AddDone;
|
||||||
|
end
|
||||||
|
else
|
||||||
|
AddSkipped;
|
||||||
eStr.Free;
|
eStr.Free;
|
||||||
AddDone;
|
|
||||||
{ create directories }
|
{ create directories }
|
||||||
AddStatus('Creating directories...', clBlack);
|
AddStatus('Creating directories...', clBlack);
|
||||||
end;
|
end;
|
||||||
@ -422,44 +440,45 @@ begin
|
|||||||
|
|
||||||
if not IsForbidden(FileList[i], OS) then begin
|
if not IsForbidden(FileList[i], OS) then begin
|
||||||
if Pos('base', FileList[i]) = 1 then begin
|
if Pos('base', FileList[i]) = 1 then begin
|
||||||
|
AddStatus('Copying file: addons\amxmodx\' + Copy(FileList[i], 6, Length(FileList[i])), clBlack);
|
||||||
FileCopy(ExtractFilePath(ParamStr(0)) + 'files\' + FileList[i], ePath + 'addons\amxmodx\' + Copy(FileList[i], 6, Length(FileList[i])), CopyConfig);
|
FileCopy(ExtractFilePath(ParamStr(0)) + 'files\' + FileList[i], ePath + 'addons\amxmodx\' + Copy(FileList[i], 6, Length(FileList[i])), CopyConfig);
|
||||||
AddStatus('Copied file: addons\amxmodx\' + Copy(FileList[i], 6, Length(FileList[i])), clBlack);
|
|
||||||
end;
|
end;
|
||||||
|
|
||||||
case eMod of
|
case eMod of
|
||||||
modCS: begin
|
modCS: begin
|
||||||
if Pos('cstrike', FileList[i]) = 1 then begin
|
if Pos('cstrike', FileList[i]) = 1 then begin
|
||||||
|
AddStatus('Copying file: addons\amxmodx\' + Copy(FileList[i], 9, Length(FileList[i])), clBlack);
|
||||||
FileCopy(ExtractFilePath(ParamStr(0)) + 'files\' + FileList[i], ePath + 'addons\amxmodx\' + Copy(FileList[i], 9, Length(FileList[i])), CopyConfig);
|
FileCopy(ExtractFilePath(ParamStr(0)) + 'files\' + FileList[i], ePath + 'addons\amxmodx\' + Copy(FileList[i], 9, Length(FileList[i])), CopyConfig);
|
||||||
AddStatus('Copied file: addons\amxmodx\' + Copy(FileList[i], 9, Length(FileList[i])), clBlack);
|
|
||||||
end;
|
end;
|
||||||
end;
|
end;
|
||||||
modDoD: begin
|
modDoD: begin
|
||||||
if Pos('dod', FileList[i]) = 1 then begin
|
if Pos('dod', FileList[i]) = 1 then begin
|
||||||
|
AddStatus('Copying file: addons\amxmodx\' + Copy(FileList[i], 5, Length(FileList[i])), clBlack);
|
||||||
FileCopy(ExtractFilePath(ParamStr(0)) + 'files\' + FileList[i], ePath + 'addons\amxmodx\' + Copy(FileList[i], 5, Length(FileList[i])), CopyConfig);
|
FileCopy(ExtractFilePath(ParamStr(0)) + 'files\' + FileList[i], ePath + 'addons\amxmodx\' + Copy(FileList[i], 5, Length(FileList[i])), CopyConfig);
|
||||||
AddStatus('Copied file: addons\amxmodx\' + Copy(FileList[i], 5, Length(FileList[i])), clBlack);
|
|
||||||
end;
|
end;
|
||||||
end;
|
end;
|
||||||
modTFC: begin
|
modTFC: begin
|
||||||
if Pos('tfc', FileList[i]) = 1 then begin
|
if Pos('tfc', FileList[i]) = 1 then begin
|
||||||
|
AddStatus('Copying file: addons\amxmodx\' + Copy(FileList[i], 5, Length(FileList[i])), clBlack);
|
||||||
FileCopy(ExtractFilePath(ParamStr(0)) + 'files\' + FileList[i], ePath + 'addons\amxmodx\' + Copy(FileList[i], 5, Length(FileList[i])), CopyConfig);
|
FileCopy(ExtractFilePath(ParamStr(0)) + 'files\' + FileList[i], ePath + 'addons\amxmodx\' + Copy(FileList[i], 5, Length(FileList[i])), CopyConfig);
|
||||||
AddStatus('Copied file: addons\amxmodx\' + Copy(FileList[i], 5, Length(FileList[i])), clBlack);
|
|
||||||
end;
|
end;
|
||||||
end;
|
end;
|
||||||
modNS: begin
|
modNS: begin
|
||||||
if Pos('ns', FileList[i]) = 1 then begin
|
if Pos('ns', FileList[i]) = 1 then begin
|
||||||
|
AddStatus('Copying file: addons\amxmodx\' + Copy(FileList[i], 4, Length(FileList[i])), clBlack);
|
||||||
FileCopy(ExtractFilePath(ParamStr(0)) + 'files\' + FileList[i], ePath + 'addons\amxmodx\' + Copy(FileList[i], 4, Length(FileList[i])), CopyConfig);
|
FileCopy(ExtractFilePath(ParamStr(0)) + 'files\' + FileList[i], ePath + 'addons\amxmodx\' + Copy(FileList[i], 4, Length(FileList[i])), CopyConfig);
|
||||||
AddStatus('Copied file: addons\amxmodx\' + Copy(FileList[i], 4, Length(FileList[i])), clBlack);
|
|
||||||
end;
|
end;
|
||||||
end;
|
end;
|
||||||
modTS: begin
|
modTS: begin
|
||||||
if Pos('ts', FileList[i]) = 1 then begin
|
if Pos('ts', FileList[i]) = 1 then begin
|
||||||
|
AddStatus('Copying file: addons\amxmodx\' + Copy(FileList[i], 4, Length(FileList[i])), clBlack);
|
||||||
FileCopy(ExtractFilePath(ParamStr(0)) + 'files\' + FileList[i], ePath + 'addons\amxmodx\' + Copy(FileList[i], 4, Length(FileList[i])), CopyConfig);
|
FileCopy(ExtractFilePath(ParamStr(0)) + 'files\' + FileList[i], ePath + 'addons\amxmodx\' + Copy(FileList[i], 4, Length(FileList[i])), CopyConfig);
|
||||||
AddStatus('Copied file: addons\amxmodx\' + Copy(FileList[i], 4, Length(FileList[i])), clBlack);
|
|
||||||
end;
|
end;
|
||||||
end;
|
end;
|
||||||
modESF: begin
|
modESF: begin
|
||||||
if Pos('esforce', FileList[i]) = 1 then begin
|
if Pos('esforce', FileList[i]) = 1 then begin
|
||||||
|
AddStatus('Copying file: addons\amxmodx\' + Copy(FileList[i], 4, Length(FileList[i])), clBlack);
|
||||||
FileCopy(ExtractFilePath(ParamStr(0)) + 'files\' + FileList[i], ePath + 'addons\amxmodx\' + Copy(FileList[i], 4, Length(FileList[i])), CopyConfig);
|
FileCopy(ExtractFilePath(ParamStr(0)) + 'files\' + FileList[i], ePath + 'addons\amxmodx\' + Copy(FileList[i], 4, Length(FileList[i])), CopyConfig);
|
||||||
AddStatus('Copied file: addons\amxmodx\' + Copy(FileList[i], 4, Length(FileList[i])), clBlack);
|
|
||||||
end;
|
end;
|
||||||
end;
|
end;
|
||||||
end;
|
end;
|
||||||
@ -468,9 +487,11 @@ begin
|
|||||||
frmMain.ggeItem.Progress := i;
|
frmMain.ggeItem.Progress := i;
|
||||||
end;
|
end;
|
||||||
{ metamod }
|
{ metamod }
|
||||||
FileCopy(ePath + 'addons\amxmodx\dlls\metamod.dll', ePath + '\addons\metamod\dlls\metamod.dll', CopyConfig);
|
AddStatus('Copying Metamod...', clBlack);
|
||||||
FileCopy(ePath + '\addons\amxmodx\dlls\metamod_i386.so', ePath + '\addons\metamod\dlls\metamod_i386.so', CopyConfig);
|
FileCopy(ePath + 'addons\amxmodx\dlls\metamod.dll', ePath + '\addons\metamod\dlls\metamod.dll', CopyConfig, False);
|
||||||
FileCopy(ePath + '\addons\amxmodx\dlls\metamod_amd64.so', ePath + '\addons\metamod\dlls\metamod_amd64.so', CopyConfig);
|
FileCopy(ePath + '\addons\amxmodx\dlls\metamod_i386.so', ePath + '\addons\metamod\dlls\metamod_i386.so', CopyConfig, False);
|
||||||
|
FileCopy(ePath + '\addons\amxmodx\dlls\metamod_amd64.so', ePath + '\addons\metamod\dlls\metamod_amd64.so', CopyConfig, False);
|
||||||
|
|
||||||
try
|
try
|
||||||
if FileExists(ePath + '\addons\amxmodx\dlls\metamod.dll') then DeleteFile(PChar(ePath + '\addons\amxmodx\dlls\metamod.dll'));
|
if FileExists(ePath + '\addons\amxmodx\dlls\metamod.dll') then DeleteFile(PChar(ePath + '\addons\amxmodx\dlls\metamod.dll'));
|
||||||
if FileExists(ePath + '\addons\amxmodx\dlls\metamod_amd64.so') then DeleteFile(PChar(ePath + '\addons\amxmodx\dlls\metamod_amd64.so'));
|
if FileExists(ePath + '\addons\amxmodx\dlls\metamod_amd64.so') then DeleteFile(PChar(ePath + '\addons\amxmodx\dlls\metamod_amd64.so'));
|
||||||
@ -488,6 +509,7 @@ begin
|
|||||||
eStr.SaveToFile(ePath + 'addons\metamod\plugins.ini');
|
eStr.SaveToFile(ePath + 'addons\metamod\plugins.ini');
|
||||||
eStr.Free;
|
eStr.Free;
|
||||||
end;
|
end;
|
||||||
|
AddDone;
|
||||||
|
|
||||||
// finish...
|
// finish...
|
||||||
frmMain.ggeAll.Progress := frmMain.ggeAll.MaxValue;
|
frmMain.ggeAll.Progress := frmMain.ggeAll.MaxValue;
|
||||||
@ -534,11 +556,27 @@ end;
|
|||||||
{ FTP }
|
{ FTP }
|
||||||
|
|
||||||
procedure InstallFTP(eMod: TMod; OS: TOS);
|
procedure InstallFTP(eMod: TMod; OS: TOS);
|
||||||
|
function DoReconnect: Boolean;
|
||||||
|
begin
|
||||||
|
Result := False;
|
||||||
|
if MessageBox(frmMain.Handle, 'You have been disconnected due to an error. Try to reconnect?', PChar(Application.Title), MB_ICONQUESTION + MB_YESNO) = mrYes then begin
|
||||||
|
try
|
||||||
|
frmMain.IdFTP.Connect;
|
||||||
|
Result := True;
|
||||||
|
except
|
||||||
|
MessageBox(frmMain.Handle, 'Failed to reconnect. Installation aborted.', PChar(Application.Title), MB_ICONSTOP);
|
||||||
|
end;
|
||||||
|
end;
|
||||||
|
end;
|
||||||
|
|
||||||
|
label CreateAgain;
|
||||||
|
label UploadAgain;
|
||||||
var eStr: TStringList;
|
var eStr: TStringList;
|
||||||
i: integer;
|
i: integer;
|
||||||
ePath: String;
|
ePath: String;
|
||||||
CurNode: TTreeNode;
|
CurNode: TTreeNode;
|
||||||
CopyConfig: Boolean;
|
CopyConfig: Boolean;
|
||||||
|
eGoBack: Boolean;
|
||||||
begin
|
begin
|
||||||
frmMain.cmdCancel.Show;
|
frmMain.cmdCancel.Show;
|
||||||
frmMain.cmdNext.Hide;
|
frmMain.cmdNext.Hide;
|
||||||
@ -614,9 +652,36 @@ begin
|
|||||||
if Cancel then
|
if Cancel then
|
||||||
exit;
|
exit;
|
||||||
|
|
||||||
FTPMakeDir(ePath + DirList[i]);
|
AddStatus('Creating directory: ' + DirList[i], clBlack);
|
||||||
AddStatus('Created directory: ' + DirList[i], clBlack);
|
CreateAgain:
|
||||||
|
try
|
||||||
|
eGoBack := False;
|
||||||
|
FTPMakeDir(ePath + DirList[i]);
|
||||||
|
except
|
||||||
|
on E: Exception do begin
|
||||||
|
if Cancel then exit;
|
||||||
|
|
||||||
|
if frmMain.IdFTP.Connected then begin
|
||||||
|
if MessageBox(frmMain.Handle, PChar('An error occured while creating "' + FileList[i] + '"!' + #13 + E.Message + #13 + #13 + 'Retry?'), PChar(Application.Title), MB_ICONSTOP + MB_YESNO) = mrYes then
|
||||||
|
eGoBack := True
|
||||||
|
else begin
|
||||||
|
Screen.Cursor := crDefault;
|
||||||
|
Application.Terminate;
|
||||||
|
exit;
|
||||||
|
end;
|
||||||
|
end
|
||||||
|
else if not DoReconnect then
|
||||||
|
exit
|
||||||
|
else
|
||||||
|
eGoBack := True;
|
||||||
|
end;
|
||||||
|
end;
|
||||||
|
|
||||||
|
if eGoBack then
|
||||||
|
goto CreateAgain;
|
||||||
|
|
||||||
|
AddDone;
|
||||||
|
|
||||||
frmMain.ggeAll.Progress := i;
|
frmMain.ggeAll.Progress := i;
|
||||||
frmMain.ggeItem.Progress := i;
|
frmMain.ggeItem.Progress := i;
|
||||||
end;
|
end;
|
||||||
@ -629,27 +694,47 @@ begin
|
|||||||
if Cancel then
|
if Cancel then
|
||||||
exit;
|
exit;
|
||||||
|
|
||||||
if (not IsForbidden(FileList[i], OS)) and (FileExists(ExtractFilePath(ParamStr(0)) + 'temp\' + FileList[i])) then begin
|
if not IsForbidden(FileList[i], OS) then begin
|
||||||
AddStatus('Uploading file: ' + FileList[i], clBlack);
|
AddStatus('Uploading file: ' + FileList[i], clBlack);
|
||||||
frmMain.ggeItem.MaxValue := FSize(ExtractFilePath(ParamStr(0)) + 'temp\' + FileList[i]);
|
if FileExists(ExtractFilePath(ParamStr(0)) + 'temp\' + FileList[i]) then begin
|
||||||
try
|
frmMain.ggeItem.MaxValue := FSize(ExtractFilePath(ParamStr(0)) + 'temp\' + FileList[i]);
|
||||||
if LowerCase(FileList[i]) = 'liblist.gam' then
|
UploadAgain:
|
||||||
frmMain.IdFTP.Site('CHMOD 744 liblist.gam');
|
try
|
||||||
UploadFile(ExtractFilePath(ParamStr(0)) + 'temp\' + FileList[i], ePath + FileList[i], CopyConfig);
|
eGoBack := False;
|
||||||
if LowerCase(FileList[i]) = 'liblist.gam' then
|
|
||||||
frmMain.IdFTP.Size('CHMOD 444 liblist.gam');
|
if FileList[i] = 'liblist.gam' then
|
||||||
except
|
frmMain.IdFTP.Site('CHMOD 744 liblist.gam');
|
||||||
on E: Exception do begin
|
UploadFile(ExtractFilePath(ParamStr(0)) + 'temp\' + FileList[i], ePath + FileList[i], CopyConfig);
|
||||||
if not Cancel then
|
if FileList[i] = 'liblist.gam' then
|
||||||
MessageBox(frmMain.Handle, PChar('An error occured while uploading "' + FileList[i] + '"!' + #13 + E.Message), PChar(Application.Title), MB_ICONSTOP);
|
frmMain.IdFTP.Size('CHMOD 444 liblist.gam');
|
||||||
Screen.Cursor := crDefault;
|
except
|
||||||
Application.Terminate;
|
on E: Exception do begin
|
||||||
exit;
|
if Cancel then exit;
|
||||||
|
|
||||||
|
if frmMain.IdFTP.Connected then begin
|
||||||
|
if MessageBox(frmMain.Handle, PChar('An error occured while uploading "' + FileList[i] + '"!' + #13 + E.Message + #13 + #13 + 'Retry?'), PChar(Application.Title), MB_ICONSTOP + MB_YESNO) = mrYes then
|
||||||
|
eGoBack := True
|
||||||
|
else begin
|
||||||
|
Screen.Cursor := crDefault;
|
||||||
|
Application.Terminate;
|
||||||
|
exit;
|
||||||
|
end;
|
||||||
|
end
|
||||||
|
else if not DoReconnect then
|
||||||
|
exit
|
||||||
|
else
|
||||||
|
eGoBack := True;
|
||||||
|
end;
|
||||||
end;
|
end;
|
||||||
end;
|
|
||||||
|
if eGoBack then
|
||||||
|
goto UploadAgain;
|
||||||
|
end
|
||||||
|
else
|
||||||
|
AddNotFound;
|
||||||
end;
|
end;
|
||||||
frmMain.ggeAll.Progress := frmMain.ggeAll.Progress + 1;
|
frmMain.ggeAll.Progress := frmMain.ggeAll.Progress + 1;
|
||||||
frmMain.ggeItem.Progress := i;
|
frmMain.ggeItem.Progress := 0;
|
||||||
end;
|
end;
|
||||||
frmMain.ggeAll.Progress := frmMain.ggeAll.MaxValue;
|
frmMain.ggeAll.Progress := frmMain.ggeAll.MaxValue;
|
||||||
frmMain.ggeItem.Progress := frmMain.ggeItem.MaxValue;
|
frmMain.ggeItem.Progress := frmMain.ggeItem.MaxValue;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user