Nathan Durnan avatar Nathan Durnan committed 2ce5874

Report Orphaned Backups even when not purging.
See Issue #4 at BitBucket.

Comments (0)

Files changed (2)

 .hgignore,1326153052.39
 .hgsub,1325791137.19
 .hgsubstate,1325791876.03
-_HgPreBackup.au3,1326760509.09
+_HgPreBackup.au3,1326761568.72
 HgPreBackup.ico,1325031982.39
 HgPreBackup.svg,1325032006.66
 HgPreBackup_x64.exe,1326752358.3
 		If Not $bFoundMatch Then
 			;Backup not found in Source.
 			ConsoleWrite(@TAB & "Backup no longer in Source!" & @CRLF)
-			_LogFileAddMessage($Gh_LogFile, "Purging Orphaned Backup: " & $Ga_BackupRepoList[$ii])
 			$iResult = _ArrayAdd($Ga_PurgedBackupList, $Ga_BackupRepoList[$ii])
 			If ($iResult > 0) Then
 				$Ga_PurgedBackupList[0] = $iResult
 			EndIf ;Check results of adding item to array.
-			$iResult = FileRecycle($Ga_BackupRepoList[$ii])
-			If ($iResult > 0) Then
-				$jj = _ArrayDelete($Ga_BackupRepoList, $ii)
-				If ($jj >= 0) Then
-					$Ga_BackupRepoList[0] = ($jj - 1) ;don't count the first item - is is placeholder for count only!
-					$ii -= 1 ;Jump back one index to make up for removed item on next loop.
-				EndIf ;Check for successful array item deletion.
-			EndIf ;Check for successful repository deletion.
+			If Not $Gb_PurgeBackups Then
+				;Just report orphans found.
+				_LogFileAddMessage($Gh_LogFile, "Found Orphaned Backup: " & $Ga_BackupRepoList[$ii])
+			Else ;Purging Orphaned Backups.
+				_LogFileAddMessage($Gh_LogFile, "Purging Orphaned Backup: " & $Ga_BackupRepoList[$ii])
+				$iResult = FileRecycle($Ga_BackupRepoList[$ii])
+				If ($iResult > 0) Then
+					$jj = _ArrayDelete($Ga_BackupRepoList, $ii)
+					If ($jj >= 0) Then
+						$Ga_BackupRepoList[0] = ($jj - 1) ;don't count the first item - is is placeholder for count only!
+						$ii -= 1 ;Jump back one index to make up for removed item on next loop.
+					EndIf ;Check for successful array item deletion.
+				EndIf ;Check for successful repository deletion.
+			EndIf ;Check for PurgeBackups setting.
 		EndIf ;Check for backup not found in source.
 		$ii += 1 ;Increment Loop Variable.
 	Until ($ii > $Ga_BackupRepoList[0]) ;Loop through backup repositories.
 			EndIf ;Check for Validation Errors
 		EndIf ;check for any repositories found.
 		If ($Ga_PurgedBackupList[0] > 0) Then
-			$myResult = $myResult And FileWriteLine($IN_hLogFile, "|     Orphaned Backups Purged.: " & $Ga_PurgedBackupList[0])
-			$myResult = $myResult And FileWriteLine($IN_hLogFile, "|       The following no longer have matching source repositories")
-			$myResult = $myResult And FileWriteLine($IN_hLogFile, "|       and have been moved to the Recycle Bin: ")
+			$myResult = $myResult And FileWriteLine($IN_hLogFile, "|     Orphaned Backups Found..: " & $Ga_PurgedBackupList[0])
+			If Not $Gb_PurgeBackups Then
+				$myResult = $myResult And FileWriteLine($IN_hLogFile, "|       The following no longer have matching source repositories")
+				$myResult = $myResult And FileWriteLine($IN_hLogFile, "|       and should be evaluated as to their usefulness: ")
+			Else ;Orphans have been deleted.
+				$myResult = $myResult And FileWriteLine($IN_hLogFile, "|       The following no longer have matching source repositories")
+				$myResult = $myResult And FileWriteLine($IN_hLogFile, "|       and have been moved to the Recycle Bin: ")
+			EndIf ;Check for PurgeBackups setting.
 			For $ii = 1 to $Ga_PurgedBackupList[0]
 					$myResult = $myResult And FileWriteLine($IN_hLogFile, "|       > " & $Ga_PurgedBackupList[$ii])
 			Next ;Loop through list of repos
Tip: Filter by directory path e.g. /media app.js to search for public/media/app.js.
Tip: Use camelCasing e.g. ProjME to search for ProjectModifiedEvent.java.
Tip: Filter by extension type e.g. /repo .js to search for all .js files in the /repo directory.
Tip: Separate your search with spaces e.g. /ssh pom.xml to search for src/ssh/pom.xml.
Tip: Use ↑ and ↓ arrow keys to navigate and return to view the file.
Tip: You can also navigate files with Ctrl+j (next) and Ctrl+k (previous) and view the file with Ctrl+o.
Tip: You can also navigate files with Alt+j (next) and Alt+k (previous) and view the file with Alt+o.