Service/Dumper.php
protected function deleteExistingSitemaps($targetDir)
    {
        foreach ($this->urlsets as $urlset) {
            $basename = basename($urlset->getLoc());
            if (preg_match('/(.*)_[\d]+\.xml(?:\.gz)?$/', $basename)) {
                continue; // skip numbered files
            }
            // pattern is base name of sitemap file (with .xml cut) optionally followed by _X for numbered files
            $basename = preg_replace('/\.xml(?:\.gz)?$/', '', $basename); // cut .xml|.xml.gz
            $pattern = '/' . preg_quote($basename, '/') . '(_\d+)?\.xml(?:\.gz)?$/';
            foreach (Finder::create()->in($targetDir)->depth(0)->name($pattern)->files() as $file) {
                $this->filesystem->remove($file);
            }
        }
    }
protected function deleteExistingSitemaps($targetDir)
    {
        foreach ($this->urlsets as $urlset) {
            $basename = basename($urlset->getLoc());
            if (preg_match('/(.*)_[\d]+\.xml(?:\.gz)?$/', $basename)) {
                continue; // skip numbered files
            }
            // pattern is base name of sitemap file (with .xml cut) optionally followed by _X for numbered files
            $basename = preg_replace('/\.xml(?:\.gz)?$/', '', $basename); // cut .xml|.xml.gz
            $pattern = '/' . preg_quote($basename, '/') . '(_\d+)?\.xml(?:\.gz)?$/';
            foreach (Finder::create()->in($targetDir)->depth(0)->name($pattern)->files() as $file) {
                $this->filesystem->remove($file);
            }
        }
    }
protected function deleteExistingSitemaps ( $ targetDir ) { foreach ( $ this -> urlsets as $ urlset ) { $ basename = basename ( $ urlset -> getLoc ( ) ) ; if ( preg_match ( '/(.*)_[\d]+\.xml(?:\.gz)?$/' , $ basename ) ) { continue ; // skip numbered files } // pattern is base name of sitemap file (with .xml cut) optionally followed by _X for numbered files $ basename = preg_replace ( '/\.xml(?:\.gz)?$/' , '' , $ basename ) ; // cut .xml|.xml.gz $ pattern = '/' . preg_quote ( $ basename , '/' ) . '(_\d+)?\.xml(?:\.gz)?$/' ; foreach ( Finder :: create ( ) -> in ( $ targetDir ) -> depth ( 0 ) -> name ( $ pattern ) -> files ( ) as $ file ) { $ this -> filesystem -> remove ( $ file ) ; } } }
Deletes sitemap files matching filename patterns of newly generated files

@param string $targetDir
Deletes sitemap files matching filename patterns of newly generated files