shenshihai 2 years ago
parent
commit
82bc9cfc0c
2 changed files with 15 additions and 8 deletions
  1. 14 7
      src/PackageClass.php
  2. 1 1
      src/Utility.php

+ 14 - 7
src/PackageClass.php

@@ -15,7 +15,7 @@ class PackageClass
 			self::setProgressFailed('INITIALIZE_FAILED');
 			return false;
 		}
-		logInfo("distribute mode",self::$config['distribute-mode']);
+		logInfo("distribute mode: ",self::$config['distribute-mode']);
 		
 		//分发模式
 		if( self::$config['distribute-mode'] == 'install'){
@@ -327,7 +327,10 @@ class PackageClass
 				logInfo($repoName,"skip copy config file",$targetPath);
 			}
 			$targetPath = pathJoin($configDir,$targetName);
-			fileCopy($filePath,$targetPath);
+			if(! fileCopy($filePath,$targetPath) ){
+				logError($repoName,"config file copy failed",$filePath);
+				return false;
+			}
 		}
 		return true;
 	}*/
@@ -335,7 +338,6 @@ class PackageClass
 	//拷贝copy-files文件
 	private static function copyFiles($packageInfo)
 	{
-		logInfo("start copying files");
 		$app = self::$app;	
 		$cacheDir = $packageInfo['cacheDir'];
 		$repoName = $packageInfo['repoName'];
@@ -347,15 +349,20 @@ class PackageClass
 			$targetName = $fileInfo['target'];
 			$filePath = pathJoin($rootDir,$fileName);
 			if(! file_exists($filePath) ){
-				logError($repoName,"file not exists",$filePath);
+				logError("failed to copy file, file not exists.",$filePath);
 				return false;
 			}
 			if(!$fileInfo['override'] && file_exists($targetPath)){
-				logInfo($repoName,"skip copy file",$targetPath);
+				logInfo("skip copy file, file already exists",$targetPath);
 			}
 			$targetPath = pathJoin($rootDir,$targetName);
-			logInfo($repoName,"copy file ",$fileName," -> ",$targetName);
-			fileCopy($filePath,$targetPath);
+			if( fileCopy($filePath,$targetPath) ){
+				logInfo("succeeded to copy file",$fileName," -> ",$targetName);
+			}
+			else{
+				logError("failed to copy file, copy action failed.",$filePath);
+				return false;
+			}
 		}
 		return true;
 	}	

+ 1 - 1
src/Utility.php

@@ -95,7 +95,7 @@ function fileCopy(string $filePath, string $targetPath){
 		unlink($targetPath);
 	}
 	copy($filePath,$targetPath);
-	return true;
+	return file_exists($targetPath);
 }
 
 //枚举子目录