瀏覽代碼

ftp文件上传优化

git 2 年之前
父節點
當前提交
f2b5a4cf14
共有 1 個文件被更改,包括 10 次插入4 次删除
  1. 10 4
      Home/Lib/Action/CronAction.class.php

+ 10 - 4
Home/Lib/Action/CronAction.class.php

@@ -17,12 +17,18 @@ class CronAction extends Action {
 			array_pop($files);
 			foreach ($files as $v) {
 				$path_parts = pathinfo($v);
-				$start = time();
-				$zip = $this->zip($path_parts['filename'], $path_parts['dirname']);
+				//$start = time();
+				//判断是否需要压缩,之前压缩过但没上传成功,需要重新上传
+				$zip_file = $path_parts['dirname'].'/' . $path_parts['filename'] . '.zip';
+				if(file_exists($zip_file)){
+					$zip = $zip_file;
+				}else{
+					$zip = $this->zip($path_parts['filename'], $path_parts['dirname']);
+				}
 				if ($zip) {//压缩完成
-					echo '压缩用时:'.(time()-$start).PHP_EOL;
+					//echo '压缩用时:'.(time()-$start).PHP_EOL;
 					$tagetDat = $targetDir . '/' . $path_parts['filename'] . '.zip';
-					echo $tagetDat . PHP_EOL;
+					//echo $tagetDat . PHP_EOL;
 					//删除本地dat文件
 					@unlink($path_parts['dirname'] . '/' . $path_parts['filename'] . '.dat');
 					$datRes = Zmcoding\FtpFile::getInstance($config)->up_file($zip, $tagetDat);