Use correct suffix (.zip or .apk) when downloading app from a url.

md5calculator (used in lib/devices/android/android-common.js)
can only handle files that end in .ipa or .apk, not .zip.
Currently urls that end in .apk are downloaded as appium-app.zip
This commit is contained in:
Andrew Wason
2014-01-10 17:18:27 -05:00
parent 78bb4e14f6
commit 456fc65bd2
2 changed files with 4 additions and 4 deletions

View File

@@ -296,7 +296,7 @@ Appium.prototype.configureDownloadedApp = function(appPath, origin, cb) {
var appUrl = appPath;
if (appUrl.substring(appUrl.length - 4) === ".apk") {
try {
downloadFile(appUrl, function(appPath) {
downloadFile(appUrl, ".apk", function(appPath) {
this.tempFiles.push(appPath);
this.args.app = appPath;
cb(null);
@@ -406,7 +406,7 @@ Appium.prototype.configureChromeAndroid = function(appPath) {
};
Appium.prototype.downloadAndUnzipApp = function(appUrl, cb) {
downloadFile(appUrl, function(zipPath) {
downloadFile(appUrl, ".zip", function(zipPath) {
this.unzipApp(zipPath, cb);
}.bind(this));
};

View File

@@ -15,10 +15,10 @@ var logger = require('./server/logger.js').get('appium')
, AdmZip = require('adm-zip');
exports.downloadFile = function(fileUrl, cb) {
exports.downloadFile = function(fileUrl, suffix, cb) {
// We will be downloading the files to a directory, so make sure it's there
// This step is not required if you have manually created the directory
tempdir.open({prefix: 'appium-app', suffix: '.zip'}, function(err, info) {
tempdir.open({prefix: 'appium-app', suffix: suffix}, function(err, info) {
var file = fs.createWriteStream(info.path);
request(fileUrl).pipe(file).on('close', function() {
logger.info(fileUrl + ' downloaded to ' + info.path);