Explicit assingment of infinite timeout for uploads and downloads; delete local file when download can't finish

This commit is contained in:
David A. Velasco 2012-07-05 15:51:32 +02:00
parent 890bf7fa51
commit 93983377cc
3 changed files with 8 additions and 15 deletions

View file

@ -18,7 +18,7 @@
-->
<manifest package="eu.alefzero.owncloud"
android:versionCode="1"
android:versionName="0.1.146B" xmlns:android="http://schemas.android.com/apk/res/android">
android:versionName="0.1.147B" xmlns:android="http://schemas.android.com/apk/res/android">
<uses-permission android:name="android.permission.GET_ACCOUNTS" />
<uses-permission android:name="android.permission.USE_CREDENTIALS" />

View file

@ -148,6 +148,7 @@ public class FileDownloader extends Service implements OnDatatransferProgressLis
mAccount.name });
message = DOWNLOAD_FINISH_MESSAGE;
} else {
file.delete();
message = BAD_DOWNLOAD_MESSAGE;
}

View file

@ -97,21 +97,10 @@ public class WebdavClient extends HttpClient {
}
public boolean downloadFile(String remoteFilepath, File targetPath) {
// HttpGet get = new HttpGet(mUri.toString() + filepath.replace(" ",
// "%20"));
/* dvelasco - this is not necessary anymore; OCFile.mRemotePath (the origin of remoteFielPath) keeps valid URL strings
String[] splitted_filepath = remoteFilepath.split("/");
remoteFilepath = "";
for (String s : splitted_filepath) {
if (s.equals("")) continue;
remoteFilepath += "/" + URLEncoder.encode(s);
}
Log.e("ASD", mUri.toString() + remoteFilepath.replace(" ", "%20") + "");
GetMethod get = new GetMethod(mUri.toString()
+ remoteFilepath.replace(" ", "%20"));
*/
GetMethod get = new GetMethod(mUri.toString() + remoteFilepath);
HttpMethodParams params = get.getParams();
params.setSoTimeout(0); // that means "infinite timeout"; it's the default value, but let's make it explicit
get.setParams(params);
// get.setHeader("Host", mUri.getHost());
// get.setHeader("User-Agent", "Android-ownCloud");
@ -172,6 +161,9 @@ public class WebdavClient extends HttpClient {
entity.setOnDatatransferProgressListener(mDataTransferListener);
Log.e("ASD", f.exists() + " " + entity.getContentLength());
PutMethod put = new PutMethod(mUri.toString() + remoteTarget);
HttpMethodParams params = put.getParams();
params.setSoTimeout(0); // that means "infinite timeout"; it's the default value, but let's make it explicit
put.setParams(params);
put.setRequestEntity(entity);
Log.d(TAG, "" + put.getURI().toString());
int status = executeMethod(put);