@@ -26,8 +26,6 @@ Partial Public Class Watcher : Inherits ObservableRecipient : Implements IRecipi
2626 Private ReadOnly _logger As ILogger( Of Watcher)
2727 Private ReadOnly _settingsService As ISettingsService
2828
29- Private Const LAST_SYSTEM_MODIFIED_TIME_THRESHOLD As Integer = 180 ' 3 minutes
30-
3129 <NotifyPropertyChangedFor( NameOf (TotalSaved))>
3230 <ObservableProperty> Private _LastAnalysed As DateTime
3331 <ObservableProperty> Private _WatchedFolders As New ObservableCollection( Of WatchedFolder)
@@ -36,6 +34,7 @@ Partial Public Class Watcher : Inherits ObservableRecipient : Implements IRecipi
3634 <ObservableProperty> Private _BGCompactor As BackgroundCompactor
3735
3836 Private ReadOnly Property WatcherJSONFile As IO.FileInfo
37+ Private ReadOnly IdleSettings As IdleSettings
3938
4039 Public ReadOnly Property TotalSaved As Long
4140 Get
@@ -47,10 +46,12 @@ Partial Public Class Watcher : Inherits ObservableRecipient : Implements IRecipi
4746 Sub New (excludedFiletypes As String (), logger As ILogger( Of Watcher), settingsService As ISettingsService)
4847 _logger = logger
4948 _settingsService = settingsService
50-
5149 _DataFolder = settingsService.DataFolder
5250 WatcherJSONFile = New IO.FileInfo(IO.Path.Combine(_DataFolder.FullName, "watcher.json" ))
5351
52+ IdleSettings = New IdleSettings
53+ IdleDetector.Initialize(IdleSettings)
54+
5455 WatcherLog.WatcherStarted(logger)
5556 IsActive = True
5657
@@ -59,13 +60,14 @@ Partial Public Class Watcher : Inherits ObservableRecipient : Implements IRecipi
5960 AddHandler IdleDetector.IsIdle, AddressOf OnSystemIdle
6061 AddHandler WatchedFolders.CollectionChanged, AddressOf WatchedFolders_CollectionChanged
6162
62- BGCompactor = New BackgroundCompactor(excludedFiletypes, _logger)
63+ BGCompactor = New BackgroundCompactor(excludedFiletypes, _logger, IdleSettings )
6364 InitializeWatchedFoldersAsync()
6465
6566
6667 End Sub
6768
6869
70+
6971 Private _disableCounter As Integer = 0
7072 Private _counterLock As New SemaphoreSlim( 1 , 1 )
7173
@@ -186,7 +188,7 @@ Partial Public Class Watcher : Inherits ObservableRecipient : Implements IRecipi
186188 .LastCheckedDate = DateTime.Now
187189 .LastCheckedSize = newItem.LastCheckedSize
188190 .LastSystemModifiedDate = DateTime.Now
189- .CompressionLevel = newItem.CompressionLevel
191+ .CompressionLevel = If ( newItem.CompressionLevel <> WOFCompressionAlgorithm.NO_COMPRESSION,newItem.CompressionLevel, existingItem.CompressionLevel)
190192 End With
191193 existingItem.HasTargetChanged = False
192194 End Sub
@@ -274,7 +276,7 @@ Partial Public Class Watcher : Inherits ObservableRecipient : Implements IRecipi
274276 Try
275277
276278 If Not IsWatchingEnabled Then Return
277- Dim recentThresholdDate As DateTime = DateTime.Now.AddSeconds(-LAST_SYSTEM_MODIFIED_TIME_THRESHOLD )
279+ Dim recentThresholdDate As DateTime = DateTime.Now.AddSeconds(-IdleSettings.LastSystemModifiedTimeThresholdSeconds )
278280 If WatchedFolders.Any( Function (x) x.LastChangedDate > recentThresholdDate) Then Return
279281
280282 If _parseWatchersSemaphore.CurrentCount <> 0 Then
@@ -381,7 +383,7 @@ Partial Public Class Watcher : Inherits ObservableRecipient : Implements IRecipi
381383
382384 If analysedFiles.Count <> 0 Then
383385 Dim mainCompressionLVL = analysedFiles?.Select( Function (f) f.CompressionMode).Max
384- watched.CompressionLevel = If (mainCompressionLVL, WOFCompressionAlgorithm.NO_COMPRESSION)
386+ watched.CompressionLevel = If (mainCompressionLVL <> WOFCompressionAlgorithm.NO_COMPRESSION, mainCompressionLVL, watched.CompressionLevel )
385387
386388 If checkDiskModified Then
387389 Dim lastDiskWriteTime = analysedFiles.Select( Function (fl)
0 commit comments