mirror of
https://gitlab.com/freepascal.org/lazarus/lazarus.git
synced 2025-09-19 16:03:06 +02:00
Delete zip files after a package is installed.
git-svn-id: trunk@53445 -
This commit is contained in:
parent
05df480e06
commit
e6e3bd4ae8
@ -44,8 +44,6 @@ type
|
||||
var
|
||||
LocalRepositoryConfigFile: String;
|
||||
PackageAction: TPackageAction;
|
||||
ForceDownload: Boolean = True;
|
||||
ForceExtract: Boolean = True;
|
||||
InstallPackageList: TObjectList;
|
||||
|
||||
function MessageDlgEx(const AMsg: String; ADlgType: TMsgDlgType; AButtons:
|
||||
|
@ -163,6 +163,11 @@ resourcestring
|
||||
//options form
|
||||
rsOptions_FrmCaption = 'Options';
|
||||
rsOptions_lbRemoteRepository_Caption = 'Remote repository';
|
||||
rsOptions_cbForceDownloadExtract_Caption = 'Always force download and extract';
|
||||
rsOptions_cbForceDownloadExtract_Hint = 'If this option is checked the packages are always re-downloaded/extracted before install';
|
||||
rsOptions_cbDelete_Caption = 'Delete downloaded zip files after installation/update';
|
||||
rsOptions_cbDelete_Hint = 'If this option is checked the downloaded zip file is always deleted after installation';
|
||||
|
||||
rsOptions_cbProxy_Caption = 'Use proxy';
|
||||
rsOptions_gbProxySettings_Caption = 'Proxy settings';
|
||||
rsOptions_lbServer_Caption = 'Server';
|
||||
|
@ -604,6 +604,8 @@ begin
|
||||
|
||||
if CanGo then
|
||||
begin
|
||||
if Options.DeleteZipAfterInstall then
|
||||
SerializablePackages.DeleteDownloadedZipFiles;
|
||||
if SerializablePackages.InstallCount > 0 then
|
||||
begin
|
||||
InstallStatus := isFailed;
|
||||
@ -676,6 +678,8 @@ begin
|
||||
|
||||
if CanGo then
|
||||
begin
|
||||
if Options.DeleteZipAfterInstall then
|
||||
SerializablePackages.DeleteDownloadedZipFiles;
|
||||
if SerializablePackages.InstallCount > 0 then
|
||||
begin
|
||||
InstallStatus := isFailed;
|
||||
|
@ -44,6 +44,8 @@ type
|
||||
FProxySettings: TProxySettings;
|
||||
FXML: TXMLConfig;
|
||||
FRemoteRepository: String;
|
||||
FForceDownloadAndExtract: Boolean;
|
||||
FDeleteZipAfterInstall: Boolean;
|
||||
FChanged: Boolean;
|
||||
FLastDownloadDir: String;
|
||||
FLastPackageDirSrc: String;
|
||||
@ -63,10 +65,12 @@ type
|
||||
procedure LoadDefault;
|
||||
published
|
||||
property Changed: Boolean read FChanged write FChanged;
|
||||
property RemoteRepository: string read FRemoteRepository write SetRemoteRepository;
|
||||
property ForceDownloadAndExtract: Boolean read FForceDownloadAndExtract write FForceDownloadAndExtract;
|
||||
property DeleteZipAfterInstall: Boolean read FDeleteZipAfterInstall write FDeleteZipAfterInstall;
|
||||
property LastDownloadDir: String read FLastDownloadDir write FLastDownloadDir;
|
||||
property LastPackagedirSrc: String read FLastPackageDirSrc write FLastPackageDirSrc;
|
||||
property LastPackagedirDst: String read FLastPackageDirDst write FLastPackageDirDst;
|
||||
property RemoteRepository: string read FRemoteRepository write SetRemoteRepository;
|
||||
property ProxyEnabled: Boolean read FProxySettings.FEnabled write FProxySettings.FEnabled;
|
||||
property ProxyServer: String read FProxySettings.FServer write FProxySettings.FServer;
|
||||
property ProxyPort: Word read FProxySettings.FPort write FProxySettings.FPort;
|
||||
@ -107,6 +111,8 @@ end;
|
||||
procedure TOptions.Load;
|
||||
begin
|
||||
FRemoteRepository := FXML.GetValue('General/RemoteRepository/Value', '');
|
||||
FForceDownloadAndExtract := FXML.GetValue('General/ForceDownloadAndExtract/Value', True);
|
||||
FDeleteZipAfterInstall := FXML.GetValue('General/DeleteZipAfterInstall/Value', True);
|
||||
FLastDownloadDir := FXML.GetValue('General/LastDownloadDir/Value', '');
|
||||
FLastPackageDirSrc := FXML.GetValue('General/LastPackageDirSrc/Value', '');
|
||||
FLastPackageDirDst := FXML.GetValue('GeneralLastPackageDirDst/Value', '');
|
||||
@ -125,6 +131,8 @@ end;
|
||||
procedure TOptions.Save;
|
||||
begin
|
||||
FXML.SetDeleteValue('General/RemoteRepository/Value', FRemoteRepository, '');
|
||||
FXML.SetDeleteValue('General/ForceDownloadAndExtract/Value', FForceDownloadAndExtract, True);
|
||||
FXML.SetDeleteValue('General/DeleteZipAfterInstall/Value', FDeleteZipAfterInstall, True);
|
||||
FXML.SetDeleteValue('General/LastDownloadDir/Value', FLastDownloadDir, '');
|
||||
FXML.SetDeleteValue('General/LastPackageDirSrc/Value', FLastPackageDirSrc, '');
|
||||
FXML.SetDeleteValue('LastPackageDirDst/Value', FLastPackageDirDst, '');
|
||||
@ -148,6 +156,8 @@ var
|
||||
LocalRepository: String;
|
||||
begin
|
||||
FRemoteRepository := 'http://packages.lazarus-ide.org/';
|
||||
FForceDownloadAndExtract := True;
|
||||
FDeleteZipAfterInstall := True;
|
||||
|
||||
FProxySettings.FEnabled := False;
|
||||
FProxySettings.FServer := '';
|
||||
|
@ -1,5 +1,5 @@
|
||||
object OptionsFrm: TOptionsFrm
|
||||
Left = 611
|
||||
Left = 661
|
||||
Height = 300
|
||||
Top = 304
|
||||
Width = 450
|
||||
@ -96,6 +96,26 @@ object OptionsFrm: TOptionsFrm
|
||||
TabOrder = 0
|
||||
Text = 'http://localhost/packages/'
|
||||
end
|
||||
object cbForceDownloadExtract: TCheckBox
|
||||
Left = 15
|
||||
Height = 19
|
||||
Top = 73
|
||||
Width = 235
|
||||
Caption = ' Force download and extract of packages'
|
||||
ParentShowHint = False
|
||||
ShowHint = True
|
||||
TabOrder = 1
|
||||
end
|
||||
object cbDeleteZipAfterInstall: TCheckBox
|
||||
Left = 15
|
||||
Height = 19
|
||||
Top = 104
|
||||
Width = 294
|
||||
Caption = 'Delete downloaded zip files after installation/update'
|
||||
ParentShowHint = False
|
||||
ShowHint = True
|
||||
TabOrder = 2
|
||||
end
|
||||
end
|
||||
end
|
||||
object tsProxy: TTabSheet
|
||||
@ -363,7 +383,7 @@ object OptionsFrm: TOptionsFrm
|
||||
end
|
||||
end
|
||||
object SDD: TSelectDirectoryDialog
|
||||
left = 200
|
||||
top = 80
|
||||
left = 272
|
||||
top = 32
|
||||
end
|
||||
end
|
||||
|
@ -45,6 +45,8 @@ type
|
||||
bLocalRepositoryPackages: TSpeedButton;
|
||||
bRestore: TButton;
|
||||
cbProxy: TCheckBox;
|
||||
cbForceDownloadExtract: TCheckBox;
|
||||
cbDeleteZipAfterInstall: TCheckBox;
|
||||
edLocalRepositoryPackages: TEdit;
|
||||
edLocalRepositoryArchive: TEdit;
|
||||
edLocalRepositoryUpdate: TEdit;
|
||||
@ -139,6 +141,8 @@ begin
|
||||
Exit;
|
||||
end;
|
||||
Options.RemoteRepository := edRemoteRepository.Text;
|
||||
Options.ForceDownloadAndExtract := cbForceDownloadExtract.Checked;
|
||||
Options.DeleteZipAfterInstall := cbDeleteZipAfterInstall.Checked;
|
||||
Options.ProxyEnabled := cbProxy.Checked;
|
||||
Options.ProxyServer := edProxyServer.Text;
|
||||
Options.ProxyPort := seProxyPort.Value;
|
||||
@ -189,6 +193,13 @@ begin
|
||||
|
||||
lbRemoteRepository.Caption := rsOptions_lbRemoteRepository_Caption;
|
||||
edRemoteRepository.Text := Options.RemoteRepository;
|
||||
cbForceDownloadExtract.Checked := Options.ForceDownloadAndExtract;
|
||||
cbDeleteZipAfterInstall.Checked := Options.DeleteZipAfterInstall;
|
||||
|
||||
cbForceDownloadExtract.Caption := rsOptions_cbForceDownloadExtract_Caption;
|
||||
cbForceDownloadExtract.Hint := rsOptions_cbForceDownloadExtract_Hint;
|
||||
cbDeleteZipAfterInstall.Caption := rsOptions_cbDelete_Caption;
|
||||
cbDeleteZipAfterInstall.Hint := rsOptions_cbDelete_Hint;
|
||||
|
||||
cbProxy.Caption := rsOptions_cbProxy_Caption;
|
||||
gbProxySettings.Caption := rsOptions_gbProxySettings_Caption;
|
||||
|
@ -271,6 +271,7 @@ type
|
||||
function Cleanup: Integer;
|
||||
function IsDependencyOk(PackageDependency: TPackageDependency; DependencyPackage: TPackageFile): Boolean;
|
||||
function IsInstalledVersionOk(PackageDependency: TPackageDependency; InstalledVersion: String): Boolean;
|
||||
procedure DeleteDownloadedZipFiles;
|
||||
public
|
||||
property Count: Integer read GetCount;
|
||||
property DownloadCount: Integer read GetDownloadCount;
|
||||
@ -569,7 +570,7 @@ begin
|
||||
Result := (Checked) and
|
||||
(psRepository in PackageStates) and
|
||||
(not (psError in PackageStates)) and
|
||||
((ForceDownload) or ((not (psDownloaded in PackageStates)) and (not (psExtracted in PackageStates))));
|
||||
((Options.ForceDownloadAndExtract) or ((not (psDownloaded in PackageStates)) and (not (psExtracted in PackageStates))));
|
||||
end;
|
||||
end;
|
||||
|
||||
@ -582,7 +583,7 @@ begin
|
||||
Result := (Checked) and
|
||||
(psDownloaded in PackageStates) and
|
||||
(not (psError in PackageStates)) and
|
||||
((ForceExtract) or ((not (psExtracted in PackageStates)) and (not (psInstalled in PackageStates))));
|
||||
((Options.ForceDownloadAndExtract) or ((not (psExtracted in PackageStates)) and (not (psInstalled in PackageStates))));
|
||||
end;
|
||||
end;
|
||||
|
||||
@ -1280,6 +1281,28 @@ begin
|
||||
end;
|
||||
end;
|
||||
|
||||
procedure TSerializablePackages.DeleteDownloadedZipFiles;
|
||||
var
|
||||
I: Integer;
|
||||
begin
|
||||
for I := 0 to Count - 1 do
|
||||
begin
|
||||
case PackageAction of
|
||||
paInstall:
|
||||
begin
|
||||
if IsPackageDownloaded(Items[I]) then
|
||||
DeleteFile(Options.LocalRepositoryArchive + Items[I].RepositoryFileName)
|
||||
end;
|
||||
paUpdate:
|
||||
begin
|
||||
if FileExists(Options.LocalRepositoryUpdate + Items[I].RepositoryFileName) then
|
||||
DeleteFile(Options.LocalRepositoryUpdate + Items[I].RepositoryFileName)
|
||||
end;
|
||||
end;
|
||||
end;
|
||||
end;
|
||||
|
||||
|
||||
function TSerializablePackages.IsDependencyOk(PackageDependency: TPackageDependency;
|
||||
DependencyPackage: TPackageFile): Boolean;
|
||||
var
|
||||
|
Loading…
Reference in New Issue
Block a user