Cloud computing platform
Revisão | 6d0d437dcde8b222fcd07221e60caab8f94db75f (tree) |
---|---|
Hora | 2014-09-27 20:05:22 |
Autor | naoki hirata <naoki@magi...> |
Commiter | naoki hirata |
GitHubアクセスライブラリ更新。
@@ -360,7 +360,31 @@ class GitRepo | ||
360 | 360 | // Zipファイルを解凍 |
361 | 361 | if ($status){ |
362 | 362 | $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 { | |
364 | 388 | $dirName = basename($zipList[0]['filename']); // ディレクトリ名取得 |
365 | 389 | $status = $zipFile->extract(PCLZIP_OPT_PATH, $destDir); |
366 | 390 | if ($status) $destPath = $destDir . '/' . $dirName; |
@@ -394,7 +418,7 @@ class GitRepo | ||
394 | 418 | if ($srcFile){ |
395 | 419 | // Zipファイル保存用一時ファイル作成 |
396 | 420 | $tmpFile = tempnam($gEnvManager->getWorkDirPath(), M3_SYSTEM_WORK_UPLOAD_FILENAME_HEAD); |
397 | - | |
421 | + | |
398 | 422 | // 保存先ファイルを開く |
399 | 423 | $newFile = fopen($tmpFile, 'wb'); |
400 | 424 | if ($newFile){ |
@@ -405,11 +429,35 @@ class GitRepo | ||
405 | 429 | $status = true; // 読み込み完了 |
406 | 430 | } |
407 | 431 | fclose($srcFile); |
408 | - | |
432 | + | |
409 | 433 | // Zipファイルを解凍 |
410 | 434 | if ($status){ |
411 | 435 | $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 { | |
413 | 461 | $dirName = basename($zipList[0]['filename']); // ディレクトリ名取得 |
414 | 462 | $packageDirName = pathinfo($path, PATHINFO_FILENAME); |
415 | 463 | if ($zipList[0]['folder'] && strcasecmp($dirName, $packageDirName) == 0){ // パッケージ名と同じディレクトリ内にある場合 |