From f5dd7919413b9e0a34d0b14980eae2cdc58b4532 Mon Sep 17 00:00:00 2001 From: Andy <88590076+AAndyProgram@users.noreply.github.com> Date: Fri, 22 Mar 2024 01:28:49 +0300 Subject: [PATCH] 2024.3.22.0 TDownloader: exclude the last 3 days from deleting session files UserDownloadQueueForm: fix bug --- SCrawler/Download/TDownloader.vb | 7 +- SCrawler/Download/UserDownloadQueueForm.vb | 105 ++++++++++++------ .../Editors/GlobalSettingsForm.Designer.vb | 25 +++++ SCrawler/Editors/GlobalSettingsForm.resx | 40 +++++++ SCrawler/Editors/GlobalSettingsForm.vb | 9 +- SCrawler/MainFrame.vb | 15 +-- 6 files changed, 151 insertions(+), 50 deletions(-) diff --git a/SCrawler/Download/TDownloader.vb b/SCrawler/Download/TDownloader.vb index e08b725..e538350 100644 --- a/SCrawler/Download/TDownloader.vb +++ b/SCrawler/Download/TDownloader.vb @@ -196,10 +196,15 @@ Namespace DownloadObjects files = SFile.GetFiles(SessionsPath.CSFileP, "*.xml",, EDP.ReturnValue) If files.ListExists Then files.RemoveAll(Settings.Feeds.FeedSpecialRemover) End If + If files.ListExists Then + Const ds$ = "yyyyMMdd" + Dim nd$ = Now.ToString(ds), d1$ = Now.AddDays(-1).ToString(ds), d2$ = Now.AddDays(-2).ToString(ds) + files.RemoveAll(Function(f) f.Name.StartsWith(nd) Or f.Name.StartsWith(d1) Or f.Name.StartsWith(d2)) + End If Dim filesCount% = Settings.FeedStoredSessionsNumber If files.ListExists And filesCount > 0 Then Dim fe As New ErrorsDescriber(EDP.None) - Do While files.Count > filesCount : files(0).Delete(,, fe) : files.RemoveAt(0) : Loop + Do While files.Count > filesCount And files.Count > 0 : files(0).Delete(,, fe) : files.RemoveAt(0) : Loop End If End If Catch ex As Exception diff --git a/SCrawler/Download/UserDownloadQueueForm.vb b/SCrawler/Download/UserDownloadQueueForm.vb index 639c841..7695206 100644 --- a/SCrawler/Download/UserDownloadQueueForm.vb +++ b/SCrawler/Download/UserDownloadQueueForm.vb @@ -14,6 +14,8 @@ Namespace DownloadObjects Friend Class UserDownloadQueueForm Private MyVew As FormView Private ReadOnly Tokens As List(Of CancellationTokenSource) + Private Loaded As Boolean = False + Private ReadOnly Pending As List(Of ListUser) Private Structure ListUser Friend IsDownloading As Boolean Private ReadOnly _UserString As String @@ -23,11 +25,16 @@ Namespace DownloadObjects End Get End Property Friend ReadOnly Key As String + Friend ReadOnly User As IUserData Friend Sub New(ByVal _User As IUserData) - Key = _User.Key - IsDownloading = True - _UserString = DirectCast(_User, UserDataBase).ToStringForLog() - If Not _User.FriendlyName.IsEmptyString Then _UserString &= $" ({_User.FriendlyName})" + Try + User = _User + Key = _User.Key + IsDownloading = True + _UserString = DirectCast(_User, UserDataBase).ToStringForLog() + If Not _User.FriendlyName.IsEmptyString Then _UserString &= $" ({_User.FriendlyName})" + Catch + End Try End Sub Public Shared Widening Operator CType(ByVal _User As UserDataBase) As ListUser Return New ListUser(_User) @@ -46,6 +53,7 @@ Namespace DownloadObjects Public Sub New() InitializeComponent() Tokens = New List(Of CancellationTokenSource) + Pending = New List(Of ListUser) End Sub Private Sub UserDownloadQueueForm_Load(sender As Object, e As EventArgs) Handles Me.Load Try @@ -55,6 +63,15 @@ Namespace DownloadObjects MyVew.SetFormSize() End If Catch + Finally + Loaded = True + FillPending() + End Try + End Sub + Private Sub FillPending() + Try + If Pending.Count > 0 Then Pending.ForEach(Sub(u) Downloader_UserDownloadStateChanged(u.User, u.IsDownloading)) : Pending.Clear() + Catch End Try End Sub Private Sub UserDownloadQueueForm_Closing(sender As Object, e As CancelEventArgs) Handles Me.Closing @@ -64,6 +81,7 @@ Namespace DownloadObjects Private Sub UserDownloadQueueForm_Disposed(sender As Object, e As EventArgs) Handles Me.Disposed MyVew.DisposeIfReady Tokens.ListClearDispose + Pending.Clear() End Sub Private Sub UserDownloadQueueForm_KeyDown(sender As Object, e As KeyEventArgs) Handles Me.KeyDown Dim b As Boolean = True @@ -78,43 +96,68 @@ Namespace DownloadObjects End Sub Friend Sub Downloader_Downloading(ByVal Value As Boolean) Try - If Not Value Then ControlInvokeFast(LIST_QUEUE, Sub() - LIST_QUEUE.Items.Clear() - Tokens.ListClearDispose - End Sub, EDP.None) + If Not Value Then + If Not Loaded Then + Pending.Clear() + Else + ControlInvokeFast(LIST_QUEUE, Sub() + LIST_QUEUE.Items.Clear() + Tokens.ListClearDispose + End Sub, EDP.None) + End If + End If Catch End Try End Sub Friend Sub Downloader_UserDownloadStateChanged(ByVal User As IUserData, ByVal IsDownloading As Boolean) Try - ControlInvokeFast(LIST_QUEUE, Sub() - Dim u As New ListUser(User) - ApplyHandlers(User, IsDownloading) - If IsDownloading Then - LIST_QUEUE.Items.Add(u) - Else - LIST_QUEUE.Items.Remove(u) - End If - LIST_QUEUE.Refresh() - End Sub, EDP.None) + If Not Loaded Then + Dim newUser As New ListUser(User) + If IsDownloading Then + If Pending.Count = 0 OrElse Not Pending.Contains(newUser) Then Pending.Add(newUser) + Else + If Pending.Count > 0 Then Pending.Remove(newUser) + End If + Else + ControlInvokeFast(LIST_QUEUE, Sub() + Dim u As New ListUser(User) + ApplyHandlers(User, IsDownloading) + If IsDownloading Then + LIST_QUEUE.Items.Add(u) + Else + LIST_QUEUE.Items.Remove(u) + End If + LIST_QUEUE.Refresh() + End Sub, EDP.None) + End If Catch End Try End Sub Private Sub User_UserDownloadStateChanged(ByVal User As IUserData, ByVal IsDownloading As Boolean) Try - ControlInvokeFast(LIST_QUEUE, - Sub() - Dim lu As New ListUser(User) - Dim i% = LIST_QUEUE.Items.IndexOf(lu) - If i >= 0 Then - lu = LIST_QUEUE.Items(i) - If Not lu.Key.IsEmptyString And Not lu.IsDownloading = IsDownloading Then - lu.IsDownloading = IsDownloading - LIST_QUEUE.Items(i) = lu - LIST_QUEUE.Refresh() - End If - End If - End Sub, EDP.None) + If Not Loaded Then + Dim __user As New ListUser(User) + If Pending.Count > 0 Then + Dim uIndx% = Pending.IndexOf(__user) + If uIndx >= 0 Then + __user.IsDownloading = IsDownloading + Pending(uIndx) = __user + End If + End If + Else + ControlInvokeFast(LIST_QUEUE, Sub() + Dim lu As New ListUser(User) + Dim i% = LIST_QUEUE.Items.IndexOf(lu) + If i >= 0 Then + lu = LIST_QUEUE.Items(i) + If Not lu.Key.IsEmptyString And Not lu.IsDownloading = IsDownloading Then + lu.IsDownloading = IsDownloading + LIST_QUEUE.Items(i) = lu + LIST_QUEUE.Refresh() + End If + End If + End Sub, EDP.None) + End If Catch End Try End Sub diff --git a/SCrawler/Editors/GlobalSettingsForm.Designer.vb b/SCrawler/Editors/GlobalSettingsForm.Designer.vb index 0e99a35..ee2b4e0 100644 --- a/SCrawler/Editors/GlobalSettingsForm.Designer.vb +++ b/SCrawler/Editors/GlobalSettingsForm.Designer.vb @@ -83,6 +83,11 @@ Namespace Editors Dim ActionButton26 As PersonalUtilities.Forms.Controls.Base.ActionButton = New PersonalUtilities.Forms.Controls.Base.ActionButton() Dim ActionButton27 As PersonalUtilities.Forms.Controls.Base.ActionButton = New PersonalUtilities.Forms.Controls.Base.ActionButton() Dim TP_HEADERS_DEF As System.Windows.Forms.TableLayoutPanel + Dim ActionButton28 As PersonalUtilities.Forms.Controls.Base.ActionButton = New PersonalUtilities.Forms.Controls.Base.ActionButton() + Dim ActionButton29 As PersonalUtilities.Forms.Controls.Base.ActionButton = New PersonalUtilities.Forms.Controls.Base.ActionButton() + Dim ActionButton30 As PersonalUtilities.Forms.Controls.Base.ActionButton = New PersonalUtilities.Forms.Controls.Base.ActionButton() + Dim ActionButton31 As PersonalUtilities.Forms.Controls.Base.ActionButton = New PersonalUtilities.Forms.Controls.Base.ActionButton() + Dim ActionButton32 As PersonalUtilities.Forms.Controls.Base.ActionButton = New PersonalUtilities.Forms.Controls.Base.ActionButton() Dim TAB_HEADERS As System.Windows.Forms.TabPage Me.TXT_GLOBAL_PATH = New PersonalUtilities.Forms.Controls.TextBoxExtended() Me.TXT_IMAGE_LARGE = New PersonalUtilities.Forms.Controls.TextBoxExtended() @@ -2179,6 +2184,10 @@ Namespace Editors ' 'TXT_H_DEF_UserAgent ' + ActionButton28.BackgroundImage = CType(resources.GetObject("ActionButton28.BackgroundImage"), System.Drawing.Image) + ActionButton28.Name = "Clear" + ActionButton28.Tag = PersonalUtilities.Forms.Controls.Base.ActionButton.DefaultButtons.Clear + Me.TXT_H_DEF_UserAgent.Buttons.Add(ActionButton28) Me.TXT_H_DEF_UserAgent.CaptionText = "UserAgent" Me.TXT_H_DEF_UserAgent.CaptionWidth = 140.0R Me.TXT_H_DEF_UserAgent.Dock = System.Windows.Forms.DockStyle.Fill @@ -2189,6 +2198,10 @@ Namespace Editors ' 'TXT_H_DEF_sec_ch_ua ' + ActionButton29.BackgroundImage = CType(resources.GetObject("ActionButton29.BackgroundImage"), System.Drawing.Image) + ActionButton29.Name = "Clear" + ActionButton29.Tag = PersonalUtilities.Forms.Controls.Base.ActionButton.DefaultButtons.Clear + Me.TXT_H_DEF_sec_ch_ua.Buttons.Add(ActionButton29) Me.TXT_H_DEF_sec_ch_ua.CaptionText = "sec-ch-ua" Me.TXT_H_DEF_sec_ch_ua.CaptionWidth = 140.0R Me.TXT_H_DEF_sec_ch_ua.Dock = System.Windows.Forms.DockStyle.Fill @@ -2199,6 +2212,10 @@ Namespace Editors ' 'TXT_H_DEF_sec_ch_ua_full_version_list ' + ActionButton30.BackgroundImage = CType(resources.GetObject("ActionButton30.BackgroundImage"), System.Drawing.Image) + ActionButton30.Name = "Clear" + ActionButton30.Tag = PersonalUtilities.Forms.Controls.Base.ActionButton.DefaultButtons.Clear + Me.TXT_H_DEF_sec_ch_ua_full_version_list.Buttons.Add(ActionButton30) Me.TXT_H_DEF_sec_ch_ua_full_version_list.CaptionText = "sec-ch-ua-full-version-list" Me.TXT_H_DEF_sec_ch_ua_full_version_list.CaptionWidth = 140.0R Me.TXT_H_DEF_sec_ch_ua_full_version_list.Dock = System.Windows.Forms.DockStyle.Fill @@ -2209,6 +2226,10 @@ Namespace Editors ' 'TXT_H_DEF_sec_ch_ua_platform ' + ActionButton31.BackgroundImage = CType(resources.GetObject("ActionButton31.BackgroundImage"), System.Drawing.Image) + ActionButton31.Name = "Clear" + ActionButton31.Tag = PersonalUtilities.Forms.Controls.Base.ActionButton.DefaultButtons.Clear + Me.TXT_H_DEF_sec_ch_ua_platform.Buttons.Add(ActionButton31) Me.TXT_H_DEF_sec_ch_ua_platform.CaptionText = "sec-ch-ua-platform" Me.TXT_H_DEF_sec_ch_ua_platform.CaptionWidth = 140.0R Me.TXT_H_DEF_sec_ch_ua_platform.Dock = System.Windows.Forms.DockStyle.Fill @@ -2219,6 +2240,10 @@ Namespace Editors ' 'TXT_H_DEF_sec_ch_ua_platform_version ' + ActionButton32.BackgroundImage = CType(resources.GetObject("ActionButton32.BackgroundImage"), System.Drawing.Image) + ActionButton32.Name = "Clear" + ActionButton32.Tag = PersonalUtilities.Forms.Controls.Base.ActionButton.DefaultButtons.Clear + Me.TXT_H_DEF_sec_ch_ua_platform_version.Buttons.Add(ActionButton32) Me.TXT_H_DEF_sec_ch_ua_platform_version.CaptionText = "sec-ch-ua-platform-version" Me.TXT_H_DEF_sec_ch_ua_platform_version.CaptionWidth = 140.0R Me.TXT_H_DEF_sec_ch_ua_platform_version.Dock = System.Windows.Forms.DockStyle.Fill diff --git a/SCrawler/Editors/GlobalSettingsForm.resx b/SCrawler/Editors/GlobalSettingsForm.resx index 5f17a18..0c49fc9 100644 --- a/SCrawler/Editors/GlobalSettingsForm.resx +++ b/SCrawler/Editors/GlobalSettingsForm.resx @@ -577,6 +577,46 @@ You can find more detailed information about the missing posts in the form that False + + + iVBORw0KGgoAAAANSUhEUgAAABAAAAAQCAYAAAAf8/9hAAAABGdBTUEAALGPC/xhBQAAAAlwSFlzAAAO + xAAADsQBlSsOGwAAAIZJREFUOE+1j10KwCAMgz2b755xl/IsvnaL2K20UfbDAmEako+ZROSTafjE12Go + tbbB43rK5xSAQq1VYFtmeQBoqZTSreVZvgTknM8yyyjA/qodsDF9gspD2Bj6B+DH+NqzhQQAG+POMnSX + AFuc5QFgn6ClHh5iOQVAKNixyucB8NY0vG9JOzzyhrdq5IRgAAAAAElFTkSuQmCC + + + + + iVBORw0KGgoAAAANSUhEUgAAABAAAAAQCAYAAAAf8/9hAAAABGdBTUEAALGPC/xhBQAAAAlwSFlzAAAO + xAAADsQBlSsOGwAAAIZJREFUOE+1j10KwCAMgz2b755xl/IsvnaL2K20UfbDAmEako+ZROSTafjE12Go + tbbB43rK5xSAQq1VYFtmeQBoqZTSreVZvgTknM8yyyjA/qodsDF9gspD2Bj6B+DH+NqzhQQAG+POMnSX + AFuc5QFgn6ClHh5iOQVAKNixyucB8NY0vG9JOzzyhrdq5IRgAAAAAElFTkSuQmCC + + + + + iVBORw0KGgoAAAANSUhEUgAAABAAAAAQCAYAAAAf8/9hAAAABGdBTUEAALGPC/xhBQAAAAlwSFlzAAAO + xAAADsQBlSsOGwAAAIZJREFUOE+1j10KwCAMgz2b755xl/IsvnaL2K20UfbDAmEako+ZROSTafjE12Go + tbbB43rK5xSAQq1VYFtmeQBoqZTSreVZvgTknM8yyyjA/qodsDF9gspD2Bj6B+DH+NqzhQQAG+POMnSX + AFuc5QFgn6ClHh5iOQVAKNixyucB8NY0vG9JOzzyhrdq5IRgAAAAAElFTkSuQmCC + + + + + iVBORw0KGgoAAAANSUhEUgAAABAAAAAQCAYAAAAf8/9hAAAABGdBTUEAALGPC/xhBQAAAAlwSFlzAAAO + xAAADsQBlSsOGwAAAIZJREFUOE+1j10KwCAMgz2b755xl/IsvnaL2K20UfbDAmEako+ZROSTafjE12Go + tbbB43rK5xSAQq1VYFtmeQBoqZTSreVZvgTknM8yyyjA/qodsDF9gspD2Bj6B+DH+NqzhQQAG+POMnSX + AFuc5QFgn6ClHh5iOQVAKNixyucB8NY0vG9JOzzyhrdq5IRgAAAAAElFTkSuQmCC + + + + + iVBORw0KGgoAAAANSUhEUgAAABAAAAAQCAYAAAAf8/9hAAAABGdBTUEAALGPC/xhBQAAAAlwSFlzAAAO + xAAADsQBlSsOGwAAAIZJREFUOE+1j10KwCAMgz2b755xl/IsvnaL2K20UfbDAmEako+ZROSTafjE12Go + tbbB43rK5xSAQq1VYFtmeQBoqZTSreVZvgTknM8yyyjA/qodsDF9gspD2Bj6B+DH+NqzhQQAG+POMnSX + AFuc5QFgn6ClHh5iOQVAKNixyucB8NY0vG9JOzzyhrdq5IRgAAAAAElFTkSuQmCC + + False diff --git a/SCrawler/Editors/GlobalSettingsForm.vb b/SCrawler/Editors/GlobalSettingsForm.vb index f3bd7a1..f5e0c4b 100644 --- a/SCrawler/Editors/GlobalSettingsForm.vb +++ b/SCrawler/Editors/GlobalSettingsForm.vb @@ -9,6 +9,7 @@ Imports PersonalUtilities.Forms Imports PersonalUtilities.Forms.Controls Imports PersonalUtilities.Forms.Controls.Base +Imports PersonalUtilities.Functions.XML.Objects Imports ADB = PersonalUtilities.Forms.Controls.Base.ActionButton.DefaultButtons Imports StdDblClck = SCrawler.DownloadObjects.STDownloader.DoubleClickBehavior Namespace Editors @@ -207,6 +208,7 @@ Namespace Editors "If this case, the functionality of SCrawler will be limited, and some sites will not work at all.", "Environment missing"}, vbExclamation,,, {"Process", "Cancel"}) = 1 Then Exit Sub + Dim detector As Func(Of IXMLValue, Boolean) = Function(hh) hh.ChangesDetected .BeginUpdate() 'Basis @@ -242,7 +244,7 @@ Namespace Editors .HEADER_sec_ch_ua_platform.Value = TXT_H_DEF_sec_ch_ua_platform.Text .HEADER_sec_ch_ua_platform_version.Value = TXT_H_DEF_sec_ch_ua_platform_version.Text HeadersChanged = { .HEADER_UserAgent, .HEADER_sec_ch_ua, .HEADER_sec_ch_ua_full_version_list, - .HEADER_sec_ch_ua_platform, .HEADER_sec_ch_ua_platform_version}.Any(Function(hh) hh.ChangesDetected) + .HEADER_sec_ch_ua_platform, .HEADER_sec_ch_ua_platform_version}.Cast(Of IXMLValue).Any(detector) 'Behavior .ExitConfirm.Value = CH_EXIT_CONFIRM.Checked .CloseToTray.Value = CH_CLOSE_TO_TRAY.Checked @@ -333,9 +335,8 @@ Namespace Editors .FeedShowFriendlyNames.Value = CH_FEED_SHOW_FRIENDLY.Checked .FeedShowSpecialFeedsMediaItem.Value = CH_FEED_SHOW_SPEC_MEDIAITEM.Checked .FeedMoveCopyUpdateFileLocationOnMove.Value = CH_FEED_UP_FILE_LOC_MOVE.Checked - FeedParametersChanged = .FeedDataRows.ChangesDetected Or .FeedDataColumns.ChangesDetected Or - .FeedEndless.ChangesDetected Or .FeedBackColor.ChangesDetected Or - .FeedForeColor.ChangesDetected Or .FeedCenterImage.ChangesDetected + FeedParametersChanged = { .FeedDataRows, .FeedDataColumns, .FeedEndless, .FeedBackColor, + .FeedForeColor, .FeedCenterImage}.Cast(Of IXMLValue).Any(detector) .EndUpdate() End With diff --git a/SCrawler/MainFrame.vb b/SCrawler/MainFrame.vb index e8a3aba..6a65c3d 100644 --- a/SCrawler/MainFrame.vb +++ b/SCrawler/MainFrame.vb @@ -467,20 +467,7 @@ CloseResume: InfoForm.FormShow(EDP.LogMessageValue) End Sub Private Sub MENU_INFO_SHOW_QUEUE_Click(sender As Object, e As EventArgs) Handles MENU_INFO_SHOW_QUEUE.Click - ShowDownloadQueueForm() - End Sub - Private Sub ShowDownloadQueueForm(Optional ByVal Round As Integer = 0) - Try - DownloadQueue.FormShow(EDP.LogMessageValue) - Catch ex As Exception - If Round = 0 Then - ErrorsDescriber.Execute(EDP.SendToLog, ex, "ShowDownloadQueueForm_0") - If Not DownloadQueue Is Nothing Then DownloadQueue.Dispose() : DownloadQueue = Nothing - ShowDownloadQueueForm(Round + 1) - Else - ErrorsDescriber.Execute(EDP.SendToLog, ex, "ShowDownloadQueueForm") - End If - End Try + Try : DownloadQueue.FormShow(EDP.LogMessageValue) : Catch : End Try End Sub Private Sub MENU_INFO_SHOW_MISSING_Click(sender As Object, e As EventArgs) Handles MENU_INFO_SHOW_MISSING.Click MyMissingPosts.FormShow(EDP.LogMessageValue)