@@ -803,10 +803,13 @@ delete_walfiles(XLogRecPtr oldest_lsn, TimeLineID oldest_tli,
803803int
804804do_delete_instance (void )
805805{
806- parray * backup_list ;
807- int i ;
806+ parray * backup_list ;
807+ parray * xlog_files_list ;
808+ int i ;
809+ int rc ;
808810char instance_config_path [MAXPGPATH ];
809811
812+
810813/* Delete all backups. */
811814backup_list = catalog_get_backup_list (INVALID_BACKUP_ID );
812815
@@ -823,23 +826,40 @@ do_delete_instance(void)
823826parray_free (backup_list );
824827
825828/* Delete all wal files. */
826- delete_walfiles (InvalidXLogRecPtr ,0 ,instance_config .xlog_seg_size );
829+ xlog_files_list = parray_new ();
830+ dir_list_file (xlog_files_list ,arclog_path , false, false, false,0 ,FIO_BACKUP_HOST );
831+
832+ for (i = 0 ;i < parray_num (xlog_files_list );i ++ )
833+ {
834+ pgFile * wal_file = (pgFile * )parray_get (xlog_files_list ,i );
835+ if (S_ISREG (wal_file -> mode ))
836+ {
837+ rc = unlink (wal_file -> path );
838+ if (rc != 0 )
839+ elog (WARNING ,"Failed to remove file \"%s\": %s" ,
840+ wal_file -> path ,strerror (errno ));
841+ }
842+ }
843+
844+ /* Cleanup */
845+ parray_walk (xlog_files_list ,pgFileFree );
846+ parray_free (xlog_files_list );
827847
828848/* Delete backup instance config file */
829849join_path_components (instance_config_path ,backup_instance_path ,BACKUP_CATALOG_CONF_FILE );
830850if (remove (instance_config_path ))
831851{
832- elog (ERROR ,"can 't remove \"%s\": %s" ,instance_config_path ,
852+ elog (ERROR ,"Can 't remove \"%s\": %s" ,instance_config_path ,
833853strerror (errno ));
834854}
835855
836856/* Delete instance root directories */
837857if (rmdir (backup_instance_path )!= 0 )
838- elog (ERROR ,"can 't remove \"%s\": %s" ,backup_instance_path ,
858+ elog (ERROR ,"Can 't remove \"%s\": %s" ,backup_instance_path ,
839859strerror (errno ));
840860
841861if (rmdir (arclog_path )!= 0 )
842- elog (ERROR ,"can 't remove \"%s\": %s" ,arclog_path ,
862+ elog (ERROR ,"Can 't remove \"%s\": %s" ,arclog_path ,
843863strerror (errno ));
844864
845865elog (INFO ,"Instance '%s' successfully deleted" ,instance_name );