Browse Source

fix possible problem in provider zip extraction.

Taylor Otwell 13 years ago
parent
commit
e89082e3ba
1 changed files with 22 additions and 1 deletions
  1. 22 1
      laravel/cli/tasks/bundle/providers/provider.php

+ 22 - 1
laravel/cli/tasks/bundle/providers/provider.php

@@ -30,7 +30,7 @@ abstract class Provider {
 		// we have a spot to do all of our bundle extration work.
 		// we have a spot to do all of our bundle extration work.
 		$target = $work.'laravel-bundle.zip';
 		$target = $work.'laravel-bundle.zip';
 
 
-		File::put($target, file_get_contents($url));
+		File::put($target, $this->download($url));
 
 
 		$zip = new \ZipArchive;
 		$zip = new \ZipArchive;
 
 
@@ -54,4 +54,25 @@ abstract class Provider {
 		@unlink($target);
 		@unlink($target);
 	}
 	}
 
 
+	/**
+	 * Download a remote zip archive from a URL.
+	 *
+	 * @param  string  $url
+	 * @return string
+	 */
+	protected function download($url)
+	{
+		$remote = file_get_contents($url);
+
+		// If we were unable to download the zip archive correctly
+		// we'll bomb out since we don't want to extract the last
+		// zip that was put in the storage directory.
+		if ($remote === false)
+		{
+			throw new \Exception("Error downloading bundle [{$bundle}].");
+		}
+
+		return $remote;
+	}
+
 }
 }