Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fixed problem with R-instat start up #9049

Merged

Conversation

derekagorhom
Copy link
Contributor

Fixes #9042
@rdstern , @N-thony this PR is ready for review

rdstern
rdstern previously approved these changes Jul 3, 2024
Copy link
Collaborator

@rdstern rdstern left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@N-thony I don't see what I can check here, as it now doesn't show on my machine anyway. So I am approving and leaving the check to you

Comment on lines 1124 to 1175
If Directory.Exists(strAutoSaveDataFolderPath) OrElse Directory.Exists(strAutoSaveLogFolderPath) OrElse Directory.Exists(strAutoSaveInternalLogFolderPath) Then
' Define the retention policy (keep last N autosaves)
Dim retentionCount As Integer = 5 ' Example: Keep the last 5 autosaves

' Retrieve autosaved files
If Directory.Exists(strAutoSaveDataFolderPath) Then
Dim autoSaveDirectory As New DirectoryInfo(strAutoSaveDataFolderPath)
Dim files As FileInfo() = autoSaveDirectory.GetFiles("data_*.rds") ' Adjust pattern to match actual filenames

' Sort files by last write time in descending order
Dim sortedFiles As IOrderedEnumerable(Of FileInfo) = files.OrderByDescending(Function(f) f.LastWriteTime)

' Determine files to delete based on retention policy
Dim filesToDelete As IEnumerable(Of FileInfo) = sortedFiles.Skip(retentionCount)

' Delete older autosaved files
For Each file In filesToDelete
file.Delete()
Next
ElseIf Directory.Exists(strAutoSaveLogFolderPath) Then
Dim autoSaveDirectory As New DirectoryInfo(strAutoSaveLogFolderPath)
Dim files As FileInfo() = autoSaveDirectory.GetFiles("log*.R") ' Adjust pattern to match actual filenames

' Sort files by last write time in descending order
Dim sortedFiles As IOrderedEnumerable(Of FileInfo) = files.OrderByDescending(Function(f) f.LastWriteTime)

' Determine files to delete based on retention policy
Dim filesToDelete As IEnumerable(Of FileInfo) = sortedFiles.Skip(retentionCount)

' Delete older autosaved files
For Each file In filesToDelete
file.Delete()
Next
ElseIf Directory.Exists(strAutoSaveInternalLogFolderPath) Then
Dim autoSaveDirectory As New DirectoryInfo(strAutoSaveInternalLogFolderPath)
Dim files As FileInfo() = autoSaveDirectory.GetFiles("debug_log*.R") ' Adjust pattern to match actual filenames

' Sort files by last write time in descending order
Dim sortedFiles As IOrderedEnumerable(Of FileInfo) = files.OrderByDescending(Function(f) f.LastWriteTime)

' Determine files to delete based on retention policy
Dim filesToDelete As IEnumerable(Of FileInfo) = sortedFiles.Skip(retentionCount)

' Delete older autosaved files
For Each file In filesToDelete
file.Delete()
Next
End If
End If
Catch ex As Exception
MsgBox("Could not delete auto save data file at: " & strCurrentAutoSaveDataFilePath & Environment.NewLine & ex.Message)
End Try
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@derekagorhom I don't think the problem was with the retention, because we need the auto saved files when it comes to recovery.
I think this is the message @rdstern doesn't want, but I still get it after running this branch
image

@N-thony
Copy link
Collaborator

N-thony commented Jul 5, 2024

@rdstern @derekagorhom we are no longer deleting the backup files. The message was to check if R-Instat has previously crushed. So, with the new change made in the code, I created a new file called app_marker.log in the log folder, This contains a text Running and change to CleanExit when R-Instat was properly closed otherwise the text remains Running and when you run again R-Instat, we always check the text in app_marker, if Running the pop up message will show to ask for recovery because R-Instat crushed in the previous session. I'm using this file as a flag to save the status of R-Instat in different way it was previously closed i.e. CleanExit or Running then crushed.
@derekagorhom you can pull the changes I made from my branch start_up into this PR and test.

@derekagorhom
Copy link
Contributor Author

@N-thony Thanks for this, I have pulled the changes

Copy link
Collaborator

@rdstern rdstern left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I am simply approving

@N-thony N-thony merged commit f9ef52f into IDEMSInternational:master Jul 5, 2024
2 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Problem at start-up with the new release
3 participants