From 716d4067540fb557cc8bde5d05fd4a70708a5d4c Mon Sep 17 00:00:00 2001 From: Andrew O'Neil Date: Thu, 23 Aug 2007 04:00:22 +0000 Subject: [PATCH] Fixed renaming of .tar.gz and .tar.bz2 files git-svn-id: svn://svn.silverstripe.com/silverstripe/open/modules/sapphire/trunk@40724 467b73ca-7a2a-4603-9d3b-597d59a354a9 --- filesystem/File.php | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/filesystem/File.php b/filesystem/File.php index 1053187ee..14c667679 100755 --- a/filesystem/File.php +++ b/filesystem/File.php @@ -178,7 +178,12 @@ class File extends DataObject { while(file_exists("$base/$file")) { $i = isset($i) ? ($i+1) : 2; $oldFile = $file; - $file = ereg_replace('[0-9]*(\.[^.]+$)',$i . '\\1', $file); + if(substr($file, strlen($file) - strlen('.tar.gz')) == '.tar.gz' || + substr($file, strlen($file) - strlen('.tar.bz2')) == '.tar.bz2') { + $file = ereg_replace('[0-9]*(\.tar\.[^.]+$)',$i . '\\1', $file); + } else { + $file = ereg_replace('[0-9]*(\.[^.]+$)',$i . '\\1', $file); + } if($oldFile == $file && $i > 2) user_error("Couldn't fix $file with $i", E_USER_ERROR); }