Skip to content

Commit

Permalink
Avoid redundant scans for legacy source files (#11)
Browse files Browse the repository at this point in the history
These calls only need to be run during a full export. Definitely not repeated for each object exported. We may do some further cleanup later as some of these legacy files are far enough removed from the current version that the checks are probably no longer needed. See joyfullservice#527

Co-authored-by: joyfullservice <joyfullservice@users.noreply.github.com>
  • Loading branch information
josef-poetzl and joyfullservice authored Aug 27, 2024
1 parent 7fc0e27 commit c9ce015
Show file tree
Hide file tree
Showing 6 changed files with 33 additions and 10 deletions.
1 change: 0 additions & 1 deletion Version Control.accda.src/modules/clsAdpTable.cls
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,6 @@ Implements IDbComponent
'
Private Sub IDbComponent_Export(Optional strAlternatePath As String)
Dim strContent As String
ClearFilesByExtension IDbComponent_BaseFolder, "tdf" ' Legacy extension
strContent = GetSource
WriteFile strContent, Nz2(strAlternatePath, IDbComponent_SourceFile)
VCSIndex.Update Me, IIf(strAlternatePath = vbNullString, eatExport, eatAltExport), GetStringHash(strContent, True)
Expand Down
1 change: 0 additions & 1 deletion Version Control.accda.src/modules/clsDbForm.cls
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,6 @@ Implements IDbComponent
'
Private Sub IDbComponent_Export(Optional strAlternatePath As String)
Dim strHash As String
If Not Options.SavePrintVars Then ClearFilesByExtension IDbComponent_BaseFolder, "json"
strHash = SaveComponentAsText(acForm, m_Form.Name, Nz2(strAlternatePath, IDbComponent_SourceFile), Me)
VCSIndex.Update Me, IIf(strAlternatePath = vbNullString, eatExport, eatAltExport), _
strHash, GetCodeModuleHash(IDbComponent_ComponentType, m_Form.Name)
Expand Down
1 change: 0 additions & 1 deletion Version Control.accda.src/modules/clsDbRelation.cls
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,6 @@ End Sub
'
Private Sub IDbComponent_Export(Optional strAlternatePath As String)
Dim strContent As String
ClearFilesByExtension IDbComponent_BaseFolder, "txt" ' Legacy extension
strContent = GetSource
WriteFile strContent, Nz2(strAlternatePath, IDbComponent_SourceFile)
VCSIndex.Update Me, IIf(strAlternatePath = vbNullString, eatExport, eatAltExport), GetStringHash(strContent, True)
Expand Down
2 changes: 0 additions & 2 deletions Version Control.accda.src/modules/clsDbReport.cls
Original file line number Diff line number Diff line change
Expand Up @@ -37,8 +37,6 @@ Implements IDbComponent
'
Private Sub IDbComponent_Export(Optional strAlternatePath As String)
Dim strHash As String
ClearFilesByExtension IDbComponent_BaseFolder, "pv" ' Remove legacy files
If Not Options.SavePrintVars Then ClearFilesByExtension IDbComponent_BaseFolder, "json"
strHash = SaveComponentAsText(acReport, m_Report.Name, Nz2(strAlternatePath, IDbComponent_SourceFile), Me)
VCSIndex.Update Me, IIf(strAlternatePath = vbNullString, eatExport, eatAltExport), _
strHash, GetCodeModuleHash(IDbComponent_ComponentType, m_Report.Name)
Expand Down
5 changes: 0 additions & 5 deletions Version Control.accda.src/modules/clsDbTableDef.cls
Original file line number Diff line number Diff line change
Expand Up @@ -53,11 +53,6 @@ Private Sub IDbComponent_Export(Optional strAlternatePath As String)
Exit Sub
End If

' Clear any legacy extensions
ClearFilesByExtension IDbComponent_BaseFolder, "LNKD"
ClearFilesByExtension IDbComponent_BaseFolder, "bas"
ClearFilesByExtension IDbComponent_BaseFolder, "tdf"

' Get the export file name
strFile = Nz2(strAlternatePath, IDbComponent_SourceFile)

Expand Down
33 changes: 33 additions & 0 deletions Version Control.accda.src/modules/modImportExport.bas
Original file line number Diff line number Diff line change
Expand Up @@ -102,6 +102,9 @@ Public Sub ExportSource(blnFullExport As Boolean, Optional intFilter As eContain
Log.Add "Updated VCS (" & Options.GetLoadedVersion & " -> " & GetVCSVersion & ")", , , "blue"
End Select

' Perform any needed upgrades to source files
If blnFullExport Then UpgradeSourceFiles

' Run any custom sub before export
If Options.RunBeforeExport <> vbNullString Then
Log.Add "Running " & Options.RunBeforeExport & "..."
Expand Down Expand Up @@ -1474,6 +1477,36 @@ Private Sub CheckForLegacyModules()
End Sub


'---------------------------------------------------------------------------------------
' Procedure : UpgradeSourceFiles
' Author : Adam Waller
' Date : 8/7/2024
' Purpose : Removes any legacy file formats used by earlier versions of this add-in.
'---------------------------------------------------------------------------------------
'
Private Sub UpgradeSourceFiles()

Dim strBase As String

strBase = Options.GetExportFolder

' Remove legacy files by extension
ClearFilesByExtension strBase & "sqltables", "tdf"
ClearFilesByExtension strBase & "relations", "txt" ' Relationships (pre-json)
ClearFilesByExtension strBase & "report", "pv" ' Print vars text file (pre-json)
ClearFilesByExtension strBase & "tbldefs", "LNKD" ' Formerly used for linked tables
ClearFilesByExtension strBase & "tbldefs", "bas" ' Moved to XML format
ClearFilesByExtension strBase & "tbldefs", "tdf"

' Clear any print settings files if not using this option
If Not Options.SavePrintVars Then
ClearFilesByExtension "forms", "json"
ClearFilesByExtension "reports", "json"
End If

End Sub


'---------------------------------------------------------------------------------------
' Procedure : PrepareRunBootstrap
' Author : Adam Waller
Expand Down

0 comments on commit c9ce015

Please sign in to comment.