EDMI: UpdateFile WIP

This commit is contained in:
Jonathan Jenne
2022-01-25 16:29:20 +01:00
parent 0fa654bda0
commit 884c9d4546
18 changed files with 460 additions and 338 deletions

View File

@@ -119,26 +119,36 @@ Namespace DocumentResultList
Private Sub FileOpenTimer_Elapsed() Handles FileOpenTimer.Elapsed
Try
For Each oOpenFile In OpenFiles
' All files that are currently processe/updated on the outside,
' will not be checked again.
If oOpenFile.CurrentlyProcessing = False Then
Continue For
End If
' Check if the file is currently in use, and skip if it is.
Dim oIsLocked = FileEx.TestFileIsLocked(oOpenFile.FilePath)
If oIsLocked Then
Continue For
End If
' If this point is reached, we assume the file was closed again after opening it.
' ------
' Compute the current hash of the file and compare it with the one
' in the database.
Dim oOldHash = oOpenFile.Document.FileHash
Dim oNewHash = FileEx.GetChecksum(oOpenFile.FilePath)
If oNewHash.Equals(oOldHash) = False Then
' File changed
RaiseEvent FileChanged(Me, New FileChangedArgs() With {.File = oOpenFile})
oOpenFile.CurrentlyProcessing = True
Else
' If the the file did not change, remove it from the watch list
If oNewHash.Equals(oOldHash) Then
OpenFiles.Remove(oOpenFile)
Continue For
End If
' The File changed, so mark the file as being processed/updated
' and notify any listeners of the FileChanged event
oOpenFile.CurrentlyProcessing = True
RaiseEvent FileChanged(Me, New FileChangedArgs() With {.File = oOpenFile})
Next
Catch ex As Exception
Logger.Error(ex)