Fixed bug with downloading expansion files
This commit is contained in:
@@ -319,15 +319,17 @@ class DataDownloader extends Thread
|
|||||||
Status.setText( downloadCount + "/" + downloadTotal + ": " + res.getString(R.string.connecting_to, url) );
|
Status.setText( downloadCount + "/" + downloadTotal + ": " + res.getString(R.string.connecting_to, url) );
|
||||||
if( url.indexOf("obb:") == 0 ) // APK expansion file provided by Google Play
|
if( url.indexOf("obb:") == 0 ) // APK expansion file provided by Google Play
|
||||||
{
|
{
|
||||||
FileInExpansion = true;
|
|
||||||
url = url.substring("obb:".length());
|
url = url.substring("obb:".length());
|
||||||
url = Environment.getExternalStorageDirectory().getAbsolutePath() + "/Android/obb/" +
|
url = Environment.getExternalStorageDirectory().getAbsolutePath() + "/Android/obb/" +
|
||||||
Parent.getPackageName() + "/" + url + "." + Parent.getPackageName() + ".obb";
|
Parent.getPackageName() + "/" + url + "." + Parent.getPackageName() + ".obb";
|
||||||
Log.i("SDL", "Fetching file from OBB: " + url);
|
|
||||||
InputStream stream1 = null;
|
InputStream stream1 = null;
|
||||||
try {
|
try {
|
||||||
stream1 = new FileInputStream(url);
|
stream1 = new FileInputStream(url);
|
||||||
|
stream1.read();
|
||||||
stream1.close();
|
stream1.close();
|
||||||
|
Log.i("SDL", "Fetching file from expansion: " + url);
|
||||||
|
FileInExpansion = true;
|
||||||
|
break;
|
||||||
} catch( Exception e ) {
|
} catch( Exception e ) {
|
||||||
Log.i("SDL", "Failed to open file: " + url);
|
Log.i("SDL", "Failed to open file: " + url);
|
||||||
downloadUrlIndex++;
|
downloadUrlIndex++;
|
||||||
@@ -369,7 +371,6 @@ class DataDownloader extends Thread
|
|||||||
response = client.execute(request);
|
response = client.execute(request);
|
||||||
} catch (IOException e) {
|
} catch (IOException e) {
|
||||||
Log.i("SDL", "Failed to connect to " + url);
|
Log.i("SDL", "Failed to connect to " + url);
|
||||||
downloadUrlIndex++;
|
|
||||||
};
|
};
|
||||||
if( response != null )
|
if( response != null )
|
||||||
{
|
{
|
||||||
@@ -379,21 +380,25 @@ class DataDownloader extends Thread
|
|||||||
responseError = response;
|
responseError = response;
|
||||||
response = null;
|
response = null;
|
||||||
downloadUrlIndex++;
|
downloadUrlIndex++;
|
||||||
|
continue;
|
||||||
}
|
}
|
||||||
else
|
break;
|
||||||
break;
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
downloadUrlIndex++;
|
||||||
|
continue;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if( FileInExpansion )
|
if( FileInExpansion )
|
||||||
{
|
{
|
||||||
|
Log.i("SDL", "Count file size: '" + url);
|
||||||
try {
|
try {
|
||||||
|
totalLen = new File(url).length();
|
||||||
stream = new CountingInputStream(new FileInputStream(url), 8192);
|
stream = new CountingInputStream(new FileInputStream(url), 8192);
|
||||||
while( stream.skip(65536) > 0 ) { };
|
Log.i("SDL", "Count file size: '" + url + " = " + totalLen);
|
||||||
totalLen = stream.getBytesRead();
|
|
||||||
stream.close();
|
|
||||||
stream = new CountingInputStream(new FileInputStream(url), 8192);
|
|
||||||
} catch( IOException e ) {
|
} catch( IOException e ) {
|
||||||
Log.i("SDL", "Unpacking from filesystem '" + url + "' - error: " + e.toString());
|
Log.i("SDL", "Unpacking from filesystem '" + url + "' - error: " + e.toString());
|
||||||
Status.setText( res.getString(R.string.error_dl_from, url) );
|
Status.setText( res.getString(R.string.error_dl_from, url) );
|
||||||
@@ -470,8 +475,6 @@ class DataDownloader extends Thread
|
|||||||
out.write(downloadUrls[downloadUrlIndex].getBytes("UTF-8"));
|
out.write(downloadUrls[downloadUrlIndex].getBytes("UTF-8"));
|
||||||
out.flush();
|
out.flush();
|
||||||
out.close();
|
out.close();
|
||||||
} catch( FileNotFoundException e ) {
|
|
||||||
} catch( SecurityException e ) {
|
|
||||||
} catch( java.io.IOException e ) {
|
} catch( java.io.IOException e ) {
|
||||||
Status.setText( res.getString(R.string.error_write, path) + ": " + e.getMessage() );
|
Status.setText( res.getString(R.string.error_write, path) + ": " + e.getMessage() );
|
||||||
return false;
|
return false;
|
||||||
@@ -483,10 +486,12 @@ class DataDownloader extends Thread
|
|||||||
if( FileInExpansion )
|
if( FileInExpansion )
|
||||||
{
|
{
|
||||||
Writer writer = new OutputStreamWriter(new FileOutputStream(url), "UTF-8");
|
Writer writer = new OutputStreamWriter(new FileOutputStream(url), "UTF-8");
|
||||||
writer.write("Extracted and cleared\n");
|
writer.write("Extracted and truncated\n");
|
||||||
writer.close();
|
writer.close();
|
||||||
|
Log.i("SDL", "Truncated file from expansion: " + url);
|
||||||
}
|
}
|
||||||
} catch( java.io.IOException e ) {
|
} catch( java.io.IOException e ) {
|
||||||
|
Log.i("SDL", "Error truncating file from expansion: " + url);
|
||||||
};
|
};
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
|
|||||||
@@ -7,10 +7,10 @@ AppName="SuperTux"
|
|||||||
AppFullName=org.lethargik.supertux2
|
AppFullName=org.lethargik.supertux2
|
||||||
|
|
||||||
# Application version code (integer)
|
# Application version code (integer)
|
||||||
AppVersionCode=3406
|
AppVersionCode=3407
|
||||||
|
|
||||||
# Application user-visible version name (string)
|
# Application user-visible version name (string)
|
||||||
AppVersionName="0.3.4.06"
|
AppVersionName="0.3.4.07"
|
||||||
|
|
||||||
# Specify path to download application data in zip archive in the form 'Description|URL|MirrorURL^Description2|URL2|MirrorURL2^...'
|
# Specify path to download application data in zip archive in the form 'Description|URL|MirrorURL^Description2|URL2|MirrorURL2^...'
|
||||||
# If you'll start Description with '!' symbol it will be enabled by default, other downloads should be selected by user from startup config menu
|
# If you'll start Description with '!' symbol it will be enabled by default, other downloads should be selected by user from startup config menu
|
||||||
|
|||||||
Reference in New Issue
Block a user