OSDN Git Service

Use PharData class to extract tarball
authorQWp6t <QWp6t+github@xpdnc.org>
Sat, 19 Oct 2013 00:55:41 +0000 (17:55 -0700)
committerQWp6t <QWp6t+github@xpdnc.org>
Sat, 19 Oct 2013 00:55:41 +0000 (17:55 -0700)
In some environments (read: mine), tar binary cannot access temp file because it is locked by php. This will resolve that issue.

php/commands/core.php

index d8e34e7..2d3d8f2 100644 (file)
@@ -66,10 +66,14 @@ class Core_Command extends WP_CLI_Command {
                );
 
                self::_request( 'GET', $download_url, $headers, $options );
-
-               $cmd = "tar xz --strip-components=1 --directory=%s -f $temp && rm $temp";
-
-               WP_CLI::launch( sprintf( $cmd, ABSPATH ) );
+               
+               if ( class_exists( 'PharData' ) ) {
+                       $tar = new PharData( $temp );
+                       $tar->extractTo( ABSPATH, null, true );
+               } else {
+                       $cmd = "tar xz --strip-components=1 --directory=%s -f $temp && rm $temp";
+                       WP_CLI::launch( sprintf( $cmd, ABSPATH ) );
+               }
 
                WP_CLI::success( 'WordPress downloaded.' );
        }