• R/O
  • HTTP
  • SSH
  • HTTPS

magic3: Commit

Cloud computing platform


Commit MetaInfo

Revisão6d0d437dcde8b222fcd07221e60caab8f94db75f (tree)
Hora2014-09-27 20:05:22
Autornaoki hirata <naoki@magi...>
Commiternaoki hirata

Mensagem de Log

GitHubアクセスライブラリ更新。

Mudança Sumário

Diff

--- a/include/common/gitRepo.php
+++ b/include/common/gitRepo.php
@@ -360,7 +360,31 @@ class GitRepo
360360 // Zipファイルを解凍
361361 if ($status){
362362 $zipFile = new PclZip($tmpFile);
363- if (($zipList = $zipFile->listContent()) != 0){
363+ if (($zipList = $zipFile->listContent()) == 0){
364+ // メッセージを出力する
365+ echo $zipFile->errorInfo(true);
366+ echo '...retrying...';
367+
368+ // 失敗の場合はZipArchiveでリトライ
369+ $zipFile = new ZipArchive();
370+
371+ // ZIPファイルをオープン
372+ $status = $zipFile->open($tmpFile);
373+ if ($status === true) { // zipファイルのオープンに成功した場合
374+ // 圧縮ファイル内の全てのファイルを指定した解凍先に展開する
375+ $zipFile->extractTo($destDir);
376+
377+ if ($zipFile->numFiles == 1 && strEndsWith($zipFile->getNameIndex(0), '/')){
378+ $dirName = basename($zipFile->getNameIndex(0)); // ディレクトリ名取得
379+ $destPath = $destDir . '/' . $dirName;
380+ } else {
381+ $destPath = $destDir;
382+ }
383+
384+ // ZIPファイルをクローズ
385+ $zipFile->close();
386+ }
387+ } else {
364388 $dirName = basename($zipList[0]['filename']); // ディレクトリ名取得
365389 $status = $zipFile->extract(PCLZIP_OPT_PATH, $destDir);
366390 if ($status) $destPath = $destDir . '/' . $dirName;
@@ -394,7 +418,7 @@ class GitRepo
394418 if ($srcFile){
395419 // Zipファイル保存用一時ファイル作成
396420 $tmpFile = tempnam($gEnvManager->getWorkDirPath(), M3_SYSTEM_WORK_UPLOAD_FILENAME_HEAD);
397-
421+
398422 // 保存先ファイルを開く
399423 $newFile = fopen($tmpFile, 'wb');
400424 if ($newFile){
@@ -405,11 +429,35 @@ class GitRepo
405429 $status = true; // 読み込み完了
406430 }
407431 fclose($srcFile);
408-
432+
409433 // Zipファイルを解凍
410434 if ($status){
411435 $zipFile = new PclZip($tmpFile);
412- if (($zipList = $zipFile->listContent()) != 0){
436+ if (($zipList = $zipFile->listContent()) == 0){ // 解凍エラーの場合
437+ // メッセージを出力する
438+ echo $zipFile->errorInfo(true);
439+ echo '...retrying...';
440+
441+ // 失敗の場合はZipArchiveでリトライ
442+ $zipFile = new ZipArchive();
443+
444+ // ZIPファイルをオープン
445+ $status = $zipFile->open($tmpFile);
446+ if ($status === true) { // zipファイルのオープンに成功した場合
447+ // 圧縮ファイル内の全てのファイルを指定した解凍先に展開する
448+ $zipFile->extractTo($destDir);
449+
450+ if ($zipFile->numFiles == 1 && strEndsWith($zipFile->getNameIndex(0), '/')){
451+ $dirName = basename($zipFile->getNameIndex(0)); // ディレクトリ名取得
452+ $destPath = $destDir . '/' . $dirName;
453+ } else {
454+ $destPath = $destDir;
455+ }
456+
457+ // ZIPファイルをクローズ
458+ $zipFile->close();
459+ }
460+ } else {
413461 $dirName = basename($zipList[0]['filename']); // ディレクトリ名取得
414462 $packageDirName = pathinfo($path, PATHINFO_FILENAME);
415463 if ($zipList[0]['folder'] && strcasecmp($dirName, $packageDirName) == 0){ // パッケージ名と同じディレクトリ内にある場合
Show on old repository browser