From 2e70501ce88b6d27712d11d5fb8a845dda949948 Mon Sep 17 00:00:00 2001 From: dazedcat19 <59296763+dazedcat19@users.noreply.github.com> Date: Tue, 22 Sep 2020 13:11:01 +0800 Subject: [PATCH] added option to vacuum databases on exit. default false. previously always true. --- baseunits/uDownloadsManager.pas | 21 ++++++----- baseunits/uFavoritesManager.pas | 1 + languages/fmd.de.po | 4 +++ languages/fmd.el_GR.po | 4 +++ languages/fmd.en.po | 4 +++ languages/fmd.es.po | 4 +++ languages/fmd.fr.po | 4 +++ languages/fmd.id_ID.po | 4 +++ languages/fmd.pl_PL.po | 4 +++ languages/fmd.pot | 4 +++ languages/fmd.pt_BR.po | 4 +++ languages/fmd.ru_RU.po | 4 +++ languages/fmd.tr_TR.po | 4 +++ mangadownloader/forms/frmMain.lfm | 58 ++++++++++++++++++++----------- mangadownloader/forms/frmMain.lrj | 1 + mangadownloader/forms/frmMain.pas | 39 ++++++++++++--------- 16 files changed, 119 insertions(+), 45 deletions(-) diff --git a/baseunits/uDownloadsManager.pas b/baseunits/uDownloadsManager.pas index e10a1647..d93ff23f 100644 --- a/baseunits/uDownloadsManager.pas +++ b/baseunits/uDownloadsManager.pas @@ -272,6 +272,7 @@ type property SortColumn: Integer read FSortColumn write FSortColumn; property TransferRate: Integer read GetTransferRate; property Task[const TaskId: Integer]: TTaskContainer read GetTask; default; + property DB: TDownloadsDB read FDownloadsDB; end; resourcestring @@ -1359,24 +1360,28 @@ begin inherited Create; InitCriticalSection(CS_Task); InitCriticalSection(CS_ItemsActiveTask); - ForceDirectories(USERDATA_FOLDER); - DownloadedChapters := TDownloadedChaptersDB.Create; - DownloadedChapters.Filename := DOWNLOADEDCHAPTERSDB_FILE; - DownloadedChapters.OnError := @MainForm.ExceptionHandler; - DownloadedChapters.Open; + InitCriticalSection(CS_StatusCount); - Items := TTaskContainers.Create; - ItemsActiveTask := TTaskContainers.Create; isFinishTaskAccessed := False; isRunningBackup := False; isRunningBackupDownloadedChaptersList := False; isReadyForExit := False; FUpdateOrderCount:=0; - InitCriticalSection(CS_StatusCount); for ds := Low(StatusCount) to High(StatusCount) do StatusCount[ds] := 0; DisabledCount := 0; + + Items := TTaskContainers.Create; + ItemsActiveTask := TTaskContainers.Create; + + ForceDirectories(USERDATA_FOLDER); + DownloadedChapters := TDownloadedChaptersDB.Create; + DownloadedChapters.AutoVacuum:=False; + DownloadedChapters.Filename := DOWNLOADEDCHAPTERSDB_FILE; + DownloadedChapters.OnError := @MainForm.ExceptionHandler; + DownloadedChapters.Open; + FDownloadsDB := TDownloadsDB.Create(DOWNLOADSDB_FILE); FDownloadsDB.Open(False, False); end; diff --git a/baseunits/uFavoritesManager.pas b/baseunits/uFavoritesManager.pas index 526a0d67..43208270 100644 --- a/baseunits/uFavoritesManager.pas +++ b/baseunits/uFavoritesManager.pas @@ -161,6 +161,7 @@ type property isAuto: Boolean read FIsAuto write FIsAuto; property isRunning: Boolean read FIsRunning write FIsRunning; property Favorite[const Index: Integer]: TFavoriteContainer read GetFavorite; default; + property DB: TFavoritesDB read FFavoritesDB; end; resourcestring diff --git a/languages/fmd.de.po b/languages/fmd.de.po index 7618f2fc..b6e15501 100644 --- a/languages/fmd.de.po +++ b/languages/fmd.de.po @@ -1022,6 +1022,10 @@ msgstr "Remove duplicate local data when updating manga list" msgid "Use proxy" msgstr "Proxy benutzen" +#: tmainform.cboptionvacuumdatabasesonexit.caption +msgid "Vacuum databases on exit" +msgstr "" + #: tmainform.cbpngcompressionlevel.text msgctxt "tmainform.cbpngcompressionlevel.text" msgid "Fastest" diff --git a/languages/fmd.el_GR.po b/languages/fmd.el_GR.po index 23b3f2c1..5226e524 100644 --- a/languages/fmd.el_GR.po +++ b/languages/fmd.el_GR.po @@ -1014,6 +1014,10 @@ msgstr "Κατάργηση διπλότυπων τοπικών δεδομένω msgid "Use proxy" msgstr "Χρήση διακομιστή μεσολάβησης" +#: tmainform.cboptionvacuumdatabasesonexit.caption +msgid "Vacuum databases on exit" +msgstr "" + #: tmainform.cbpngcompressionlevel.text msgctxt "tmainform.cbpngcompressionlevel.text" msgid "Fastest" diff --git a/languages/fmd.en.po b/languages/fmd.en.po index 2cd3dd0f..42efbc11 100644 --- a/languages/fmd.en.po +++ b/languages/fmd.en.po @@ -1017,6 +1017,10 @@ msgstr "Remove duplicate local data when updating manga list" msgid "Use proxy" msgstr "Use proxy" +#: tmainform.cboptionvacuumdatabasesonexit.caption +msgid "Vacuum databases on exit" +msgstr "" + #: tmainform.cbpngcompressionlevel.text msgctxt "tmainform.cbpngcompressionlevel.text" msgid "Fastest" diff --git a/languages/fmd.es.po b/languages/fmd.es.po index 97bb9763..5fca470c 100644 --- a/languages/fmd.es.po +++ b/languages/fmd.es.po @@ -1022,6 +1022,10 @@ msgstr "Remover los Datos Locales Duplicados Cuando se Actualiza la Lista de Man msgid "Use proxy" msgstr "Usar Proxy" +#: tmainform.cboptionvacuumdatabasesonexit.caption +msgid "Vacuum databases on exit" +msgstr "" + #: tmainform.cbpngcompressionlevel.text msgctxt "tmainform.cbpngcompressionlevel.text" msgid "Fastest" diff --git a/languages/fmd.fr.po b/languages/fmd.fr.po index 7cb765b0..8d143e03 100644 --- a/languages/fmd.fr.po +++ b/languages/fmd.fr.po @@ -1024,6 +1024,10 @@ msgstr "Supprimer les doublons locaux lors de la mise à jour du catalogue" msgid "Use proxy" msgstr "Utiliser un proxy" +#: tmainform.cboptionvacuumdatabasesonexit.caption +msgid "Vacuum databases on exit" +msgstr "" + #: tmainform.cbpngcompressionlevel.text msgctxt "tmainform.cbpngcompressionlevel.text" msgid "Fastest" diff --git a/languages/fmd.id_ID.po b/languages/fmd.id_ID.po index 3fe56585..398254cc 100644 --- a/languages/fmd.id_ID.po +++ b/languages/fmd.id_ID.po @@ -1021,6 +1021,10 @@ msgstr "Hapus data lokal duplikat saat memutakhirkan daftar komik" msgid "Use proxy" msgstr "Gunakan proxy" +#: tmainform.cboptionvacuumdatabasesonexit.caption +msgid "Vacuum databases on exit" +msgstr "" + #: tmainform.cbpngcompressionlevel.text msgctxt "tmainform.cbpngcompressionlevel.text" msgid "Fastest" diff --git a/languages/fmd.pl_PL.po b/languages/fmd.pl_PL.po index 5530fe2c..0d4b49a3 100644 --- a/languages/fmd.pl_PL.po +++ b/languages/fmd.pl_PL.po @@ -1033,6 +1033,10 @@ msgstr "Usuwanie zduplikowane lokalne dane podczas aktualizacji listy mang" msgid "Use proxy" msgstr "Użyj proxy" +#: tmainform.cboptionvacuumdatabasesonexit.caption +msgid "Vacuum databases on exit" +msgstr "" + #: tmainform.cbpngcompressionlevel.text msgctxt "tmainform.cbpngcompressionlevel.text" msgid "Fastest" diff --git a/languages/fmd.pot b/languages/fmd.pot index a9cde439..7661626b 100644 --- a/languages/fmd.pot +++ b/languages/fmd.pot @@ -956,6 +956,10 @@ msgstr "" msgid "Use proxy" msgstr "" +#: tmainform.cboptionvacuumdatabasesonexit.caption +msgid "Vacuum databases on exit" +msgstr "" + #: tmainform.cbpngcompressionlevel.text msgid "Fastest" msgstr "" diff --git a/languages/fmd.pt_BR.po b/languages/fmd.pt_BR.po index 838d53c3..7bf04659 100644 --- a/languages/fmd.pt_BR.po +++ b/languages/fmd.pt_BR.po @@ -1021,6 +1021,10 @@ msgstr "Remover dados locais duplicados quando atualizando lista de mangás" msgid "Use proxy" msgstr "Usar proxy" +#: tmainform.cboptionvacuumdatabasesonexit.caption +msgid "Vacuum databases on exit" +msgstr "" + #: tmainform.cbpngcompressionlevel.text msgctxt "tmainform.cbpngcompressionlevel.text" msgid "Fastest" diff --git a/languages/fmd.ru_RU.po b/languages/fmd.ru_RU.po index 522d36cf..29a5ded7 100644 --- a/languages/fmd.ru_RU.po +++ b/languages/fmd.ru_RU.po @@ -1021,6 +1021,10 @@ msgstr "Удалять повторяющиеся локальные данны msgid "Use proxy" msgstr "Использовать прокси" +#: tmainform.cboptionvacuumdatabasesonexit.caption +msgid "Vacuum databases on exit" +msgstr "" + #: tmainform.cbpngcompressionlevel.text msgctxt "tmainform.cbpngcompressionlevel.text" msgid "Fastest" diff --git a/languages/fmd.tr_TR.po b/languages/fmd.tr_TR.po index 3d3dbd77..1e0599a6 100644 --- a/languages/fmd.tr_TR.po +++ b/languages/fmd.tr_TR.po @@ -1023,6 +1023,10 @@ msgstr "Manga listesini güncellerken çift yerel veriyi kaldır" msgid "Use proxy" msgstr "Proxy kullan" +#: tmainform.cboptionvacuumdatabasesonexit.caption +msgid "Vacuum databases on exit" +msgstr "" + #: tmainform.cbpngcompressionlevel.text msgctxt "tmainform.cbpngcompressionlevel.text" msgid "Fastest" diff --git a/mangadownloader/forms/frmMain.lfm b/mangadownloader/forms/frmMain.lfm index e861f1eb..074f44f3 100644 --- a/mangadownloader/forms/frmMain.lfm +++ b/mangadownloader/forms/frmMain.lfm @@ -13,6 +13,7 @@ object MainForm: TMainForm OnDestroy = FormDestroy OnWindowStateChange = FormWindowStateChange ShowHint = True + LCLVersion = '2.1.0.0' object pcMain: TPageControl Left = 2 Height = 610 @@ -37,6 +38,7 @@ object MainForm: TMainForm Align = alClient Position = 200 object pssDownloadsFilter: TPairSplitterSide + Cursor = crArrow Left = 0 Height = 574 Top = 0 @@ -180,6 +182,7 @@ object MainForm: TMainForm end end object pssDownloads: TPairSplitterSide + Cursor = crArrow Left = 205 Height = 574 Top = 0 @@ -548,6 +551,7 @@ object MainForm: TMainForm Align = alClient Position = 200 object pssInfoList: TPairSplitterSide + Cursor = crArrow Left = 0 Height = 574 Top = 0 @@ -799,6 +803,7 @@ object MainForm: TMainForm end end object pssInfo: TPairSplitterSide + Cursor = crArrow Left = 205 Height = 574 Top = 0 @@ -2775,12 +2780,12 @@ object MainForm: TMainForm Height = 500 Top = 4 Width = 845 - ActivePage = tsConnections + ActivePage = tsGeneral Align = alTop Anchors = [akTop, akLeft, akRight, akBottom] BorderSpacing.Bottom = 16 ParentFont = False - TabIndex = 2 + TabIndex = 0 TabOrder = 0 object tsGeneral: TTabSheet Caption = 'General' @@ -2796,7 +2801,7 @@ object MainForm: TMainForm Top = 8 Width = 829 HorzScrollBar.Page = 300 - VertScrollBar.Page = 439 + VertScrollBar.Page = 456 Align = alClient BorderStyle = bsNone ChildSizing.LeftRightSpacing = 4 @@ -2804,14 +2809,16 @@ object MainForm: TMainForm ChildSizing.HorizontalSpacing = 4 ChildSizing.VerticalSpacing = 4 ClientHeight = 456 - ClientWidth = 829 + ClientWidth = 812 TabOrder = 0 object gbOptionExternal: TGroupBox + AnchorSideLeft.Control = sbGeneralSettings + AnchorSideTop.Control = cbOptionVacuumDatabasesOnExit AnchorSideTop.Side = asrBottom Left = 4 Height = 118 - Top = 313 - Width = 667 + Top = 336 + Width = 650 Anchors = [akTop, akLeft, akRight] BorderSpacing.Top = 20 Caption = 'External program' @@ -2820,14 +2827,14 @@ object MainForm: TMainForm ChildSizing.HorizontalSpacing = 4 ChildSizing.VerticalSpacing = 4 ClientHeight = 98 - ClientWidth = 663 + ClientWidth = 646 ParentFont = False TabOrder = 0 object lbOptionExternal: TLabel Left = 4 Height = 15 Top = 4 - Width = 655 + Width = 638 Align = alTop Caption = 'Open manga by using external program:' ParentColor = False @@ -2836,7 +2843,7 @@ object MainForm: TMainForm Left = 4 Height = 15 Top = 50 - Width = 655 + Width = 638 Align = alTop Caption = 'Parameters:' ParentColor = False @@ -2848,7 +2855,7 @@ object MainForm: TMainForm Left = 4 Height = 23 Top = 69 - Width = 628 + Width = 611 Anchors = [akTop, akLeft, akRight] TabOrder = 1 TextHint = 'External program parameters' @@ -2858,7 +2865,7 @@ object MainForm: TMainForm AnchorSideLeft.Side = asrBottom AnchorSideTop.Control = edOptionExternalParams AnchorSideTop.Side = asrCenter - Left = 636 + Left = 619 Height = 15 Top = 73 Width = 13 @@ -2873,7 +2880,7 @@ object MainForm: TMainForm Left = 4 Height = 23 Top = 23 - Width = 655 + Width = 638 Align = alTop ButtonWidth = 23 Glyph.Data = { @@ -2958,7 +2965,7 @@ object MainForm: TMainForm Left = 4 Height = 15 Top = 8 - Width = 821 + Width = 804 Align = alTop Caption = 'Language:' ParentColor = False @@ -3070,6 +3077,17 @@ object MainForm: TMainForm Caption = 'Sort Downloads when adding new download tasks' TabOrder = 9 end + object cbOptionVacuumDatabasesOnExit: TCheckBox + AnchorSideLeft.Control = sbGeneralSettings + AnchorSideTop.Control = cbOptionSortDownloadsWhenAddingNewDownloadTasks + AnchorSideTop.Side = asrBottom + Left = 4 + Height = 19 + Top = 297 + Width = 158 + Caption = 'Vacuum databases on exit' + TabOrder = 10 + end end end object tsView: TTabSheet @@ -4521,11 +4539,11 @@ object MainForm: TMainForm ChildSizing.TopBottomSpacing = 8 ChildSizing.HorizontalSpacing = 4 ChildSizing.VerticalSpacing = 4 - ClientHeight = 449 + ClientHeight = 472 ClientWidth = 837 object pcWebsiteOptions: TPageControl Left = 4 - Height = 433 + Height = 456 Top = 8 Width = 829 ActivePage = tsWebsiteSelection @@ -4534,11 +4552,11 @@ object MainForm: TMainForm TabOrder = 0 object tsWebsiteSelection: TTabSheet Caption = 'Websites' - ClientHeight = 405 + ClientHeight = 428 ClientWidth = 821 object vtOptionMangaSiteSelection: TVirtualStringTree Left = 0 - Height = 370 + Height = 393 Top = 35 Width = 821 Align = alClient @@ -4752,8 +4770,8 @@ object MainForm: TMainForm ChildSizing.TopBottomSpacing = 4 ChildSizing.HorizontalSpacing = 4 ChildSizing.VerticalSpacing = 4 - ClientHeight = 343 - ClientWidth = 515 + ClientHeight = 428 + ClientWidth = 821 object ckEnableLogging: TCheckBox Left = 4 Height = 19 @@ -4878,7 +4896,7 @@ object MainForm: TMainForm Left = 4 Height = 23 Top = 46 - Width = 506 + Width = 812 Anchors = [akTop, akLeft, akRight] ButtonWidth = 23 Glyph.Data = { diff --git a/mangadownloader/forms/frmMain.lrj b/mangadownloader/forms/frmMain.lrj index a51a9297..e837da5d 100644 --- a/mangadownloader/forms/frmMain.lrj +++ b/mangadownloader/forms/frmMain.lrj @@ -167,6 +167,7 @@ {"hash":69131508,"name":"tmainform.cboptionminimizeonstart.caption","sourcebytes":[77,105,110,105,109,105,122,101,32,111,110,32,115,116,97,114,116],"value":"Minimize on start"}, {"hash":134851429,"name":"tmainform.cboptiondeletecompletedtasksonclose.caption","sourcebytes":[68,101,108,101,116,101,32,99,111,109,112,108,101,116,101,100,32,116,97,115,107,115,32,111,110,32,99,108,111,115,101],"value":"Delete completed tasks on close"}, {"hash":162994819,"name":"tmainform.cboptionsortdownloadswhenaddingnewdownloadtasks.caption","sourcebytes":[83,111,114,116,32,68,111,119,110,108,111,97,100,115,32,119,104,101,110,32,97,100,100,105,110,103,32,110,101,119,32,100,111,119,110,108,111,97,100,32,116,97,115,107,115],"value":"Sort Downloads when adding new download tasks"}, +{"hash":136457908,"name":"tmainform.cboptionvacuumdatabasesonexit.caption","sourcebytes":[86,97,99,117,117,109,32,100,97,116,97,98,97,115,101,115,32,111,110,32,101,120,105,116],"value":"Vacuum databases on exit"}, {"hash":380871,"name":"tmainform.tsview.caption","sourcebytes":[86,105,101,119],"value":"View"}, {"hash":126054082,"name":"tmainform.cboptionshowdownloadtoolbar.caption","sourcebytes":[83,104,111,119,32,100,111,119,110,108,111,97,100,115,32,116,111,111,108,98,97,114],"value":"Show downloads toolbar"}, {"hash":157437400,"name":"tmainform.gbdroptarget.caption","sourcebytes":[68,114,111,112,32,66,111,120],"value":"Drop Box"}, diff --git a/mangadownloader/forms/frmMain.pas b/mangadownloader/forms/frmMain.pas index d086cca2..0d146439 100644 --- a/mangadownloader/forms/frmMain.pas +++ b/mangadownloader/forms/frmMain.pas @@ -67,6 +67,7 @@ type cbOptionShowDownloadToolbar: TCheckBox; cbOptionShowDownloadToolbarLeft: TCheckBox; cbOptionShowDownloadToolbarDeleteAll: TCheckBox; + cbOptionVacuumDatabasesOnExit: TCheckBox; cbOptionUpdateListNoMangaInfo: TCheckBox; cbOptionDigitVolume: TCheckBox; cbOptionDigitChapter: TCheckBox; @@ -1428,16 +1429,15 @@ end; procedure TMainForm.FormDestroy(Sender: TObject); begin + SilentThreadManager.Free; + DLManager.Free; + FavoriteManager.Free; + dataProcess.Free; + SetLength(ChapterList, 0); - FreeAndNil(mangaInfo); - - FreeAndNil(SilentThreadManager); - FreeAndNil(DLManager); - FreeAndNil(FavoriteManager); - FreeAndNil(dataProcess); - - FreeAndNil(gifWaiting); - FreeAndNil(mangaCover); + mangaInfo.Free; + gifWaiting.Free; + mangaCover.Free; if isNormalExit then Logger.Send(QuotedStrd(Application.Title)+' exit normally [PID:'+IntToStr(GetProcessID)+']') @@ -1971,6 +1971,10 @@ begin WebsiteSettingsForm.LoadWebsiteSettings; AccountManagerForm.LoadAccounts; + //restore everything after all modules loaded + DLManager.Restore; + FavoriteManager.Restore; + //load settings_file LoadMangaOptions; LoadOptions; @@ -1980,9 +1984,6 @@ begin Logger.SendException('tmStartup Error!', E); end; - //restore everything after all modules loaded - DLManager.Restore; - FavoriteManager.Restore; if OptionAutoCheckLatestVersion then begin @@ -5107,6 +5108,7 @@ begin miChapterListHighlight.Checked := ReadBool('general', 'HighlightDownloadedChapters', True); miChapterListAscending.Checked := ReadBool('general', 'SortChapterListAscending', True); miChapterListDescending.Checked := not miChapterListAscending.Checked; + cbOptionVacuumDatabasesOnExit.Checked := ReadBool('general', 'VacuumDatabasesOnExit', False); // view cbOptionShowDownloadToolbar.Checked := ReadBool('view', 'ShowDownloadsToolbar', True); @@ -5262,6 +5264,7 @@ begin WriteBool('general', 'AddAsStopped', cbAddAsStopped.Checked); WriteBool('general', 'HighlightNewManga', miHighlightNewManga.Checked); WriteBool('general', 'HighlightDownloadedChapters', miChapterListHighlight.Checked); + WriteBool('general', 'VacuumDatabasesOnExit', cbOptionVacuumDatabasesOnExit.Checked); // view WriteBool('view', 'ShowDownloadsToolbar', cbOptionShowDownloadToolbar.Checked); @@ -5398,12 +5401,12 @@ begin if cbSelectManga.Items.Count > 0 then begin cbSelectManga.ItemIndex := 0; - // Disable download manga list dialog when applying options: - b := cbOptionShowDownloadMangalistDialog.Checked; - cbOptionShowDownloadMangalistDialog.Checked := False; + // Disable download manga list dialog when applying options: + b := cbOptionShowDownloadMangalistDialog.Checked; + cbOptionShowDownloadMangalistDialog.Checked := False; cbSelectMangaEditingDone(cbSelectManga); - // Revert state back to like it was before: - cbOptionShowDownloadMangalistDialog.Checked := b; + // Revert state back to like it was before: + cbOptionShowDownloadMangalistDialog.Checked := b; end else begin @@ -5437,6 +5440,8 @@ begin OptionEnableLoadCover := cbOptionEnableLoadCover.Checked; OptionDeleteCompletedTasksOnClose := cbOptionDeleteCompletedTasksOnClose.Checked; OptionSortDownloadsWhenAddingNewDownloadTasks := cbOptionSortDownloadsWhenAddingNewDownloadTasks.Checked; + DLManager.DB.AutoVacuum:=cbOptionVacuumDatabasesOnExit.Checked; + FavoriteManager.DB.AutoVacuum:=cbOptionVacuumDatabasesOnExit.Checked; //view ToolBarDownload.Visible := cbOptionShowDownloadToolbar.Checked;