[Fusionforge-commits] r8485 - trunk/gforge/common/frs

Alain Peyrat aljeux at libremir.placard.fr.eu.org
Wed Dec 9 21:15:21 CET 2009


Author: aljeux
Date: 2009-12-09 21:15:20 +0100 (Wed, 09 Dec 2009)
New Revision: 8485

Modified:
   trunk/gforge/common/frs/FRSFile.class.php
Log:
FRS: use php rename instead of exec(mv) to better handle filenames

Modified: trunk/gforge/common/frs/FRSFile.class.php
===================================================================
--- trunk/gforge/common/frs/FRSFile.class.php	2009-12-09 20:15:12 UTC (rev 8484)
+++ trunk/gforge/common/frs/FRSFile.class.php	2009-12-09 20:15:20 UTC (rev 8485)
@@ -158,17 +158,12 @@
 			$this->FRSRelease->FRSPackage->getFileName().'/'.
 			$this->FRSRelease->getFileName().'/';
 
-		//exec("/bin/mkdir $newfilelocation",$out);
-		//print_r($out);
-		//exec("/bin/mkdir $newfilelocation",$out);
-		//print_r($out);
-		$cmd="/bin/mv $file_location $newfilelocation$name";
-		exec($cmd,$out);
-		//echo $cmd;
-		//print_r($out);
-		if (!file_exists("$newfilelocation$name")) {
-			$this->setError(_('File cannot be moved to the permanent location').': '.$newfilelocation.$name);
-			return false;
+			rename($file_location, $newfilelocation.$name);
+
+			if (!file_exists($newfilelocation.$name)) {
+				$this->setError(_('File cannot be moved to the permanent location').': '.$newfilelocation.$name);
+				return false;
+			}
 		}
 		if (!$release_time) {
 			$release_time=time();
@@ -338,7 +333,8 @@
 			$this->FRSRelease->FRSPackage->getFileName().'/'.
 			$this->FRSRelease->getFileName().'/'.
 			$this->getName();
-		unlink($file);
+			if (file_exists($file))
+				unlink($file);
 		$result = db_query_params ('DELETE FROM frs_file WHERE file_id=$1',
 					   array ($this->getID())) ;
 		if (!$result || db_affected_rows($result) < 1) {
@@ -370,7 +366,7 @@
 			return false;
 		}
 
-		// Sanity checks 
+		// Sanity checks
 		if ( $release_id ) {
 			// Check that the new FRSRelease id exists
 			if ($FRSRelease=frsrelease_get_object($release_id)) {




More information about the Fusionforge-commits mailing list