@@ -877,24 +877,17 @@ public static PSRepositoryInfo Reset(PSCmdlet cmdletPassedIn, out string errorMs
877877 if ( File . Exists ( FullRepositoryPath ) )
878878 {
879879 backupFilePath = Path . Combine ( Path . GetTempPath ( ) , Guid . NewGuid ( ) . ToString ( ) + "_backup.xml" ) ;
880- File . Copy ( FullRepositoryPath , backupFilePath , overwrite : true ) ;
881-
882- // Delete the old file
883- File . Delete ( FullRepositoryPath ) ;
880+ Utils . MoveFiles ( FullRepositoryPath , backupFilePath , overwrite : true ) ;
884881 }
885882
886883 // Move the temporary file to the actual location
887- File . Copy ( tempFilePath , FullRepositoryPath , overwrite : true ) ;
884+ Utils . MoveFiles ( tempFilePath , FullRepositoryPath , overwrite : true ) ;
888885
889886 // Add PSGallery to the newly created store
890887 Uri psGalleryUri = new Uri ( PSGalleryRepoUri ) ;
891888 PSRepositoryInfo psGalleryRepo = Add ( PSGalleryRepoName , psGalleryUri , DefaultPriority , DefaultTrusted , repoCredentialInfo : null , repoCredentialProvider : CredentialProviderType . None , APIVersion . V2 , force : false ) ;
892889
893- // Clean up temporary and backup files on success
894- if ( File . Exists ( tempFilePath ) )
895- {
896- File . Delete ( tempFilePath ) ;
897- }
890+ // Clean up backup file on success
898891 if ( ! string . IsNullOrEmpty ( backupFilePath ) && File . Exists ( backupFilePath ) )
899892 {
900893 File . Delete ( backupFilePath ) ;
@@ -913,8 +906,7 @@ public static PSRepositoryInfo Reset(PSCmdlet cmdletPassedIn, out string errorMs
913906 {
914907 File . Delete ( FullRepositoryPath ) ;
915908 }
916- File . Copy ( backupFilePath , FullRepositoryPath , overwrite : true ) ;
917- File . Delete ( backupFilePath ) ;
909+ Utils . MoveFiles ( backupFilePath , FullRepositoryPath , overwrite : true ) ;
918910 }
919911 catch ( Exception restoreEx )
920912 {
0 commit comments