From: David A. Velasco Date: Thu, 5 Jul 2012 13:51:32 +0000 (+0200) Subject: Explicit assingment of infinite timeout for uploads and downloads; delete local file... X-Git-Tag: oc-android-1.4.3~308 X-Git-Url: http://git.linex4red.de/pub/Android/ownCloud.git/commitdiff_plain/93983377ccbedb14102d34144e83d4d28c5c2cab Explicit assingment of infinite timeout for uploads and downloads; delete local file when download can't finish --- diff --git a/AndroidManifest.xml b/AndroidManifest.xml index aa9fb399..c656db44 100644 --- a/AndroidManifest.xml +++ b/AndroidManifest.xml @@ -18,7 +18,7 @@ --> + android:versionName="0.1.147B" xmlns:android="http://schemas.android.com/apk/res/android"> diff --git a/src/eu/alefzero/owncloud/files/services/FileDownloader.java b/src/eu/alefzero/owncloud/files/services/FileDownloader.java index d6d7780a..7a88f6ab 100644 --- a/src/eu/alefzero/owncloud/files/services/FileDownloader.java +++ b/src/eu/alefzero/owncloud/files/services/FileDownloader.java @@ -148,6 +148,7 @@ public class FileDownloader extends Service implements OnDatatransferProgressLis mAccount.name }); message = DOWNLOAD_FINISH_MESSAGE; } else { + file.delete(); message = BAD_DOWNLOAD_MESSAGE; } diff --git a/src/eu/alefzero/webdav/WebdavClient.java b/src/eu/alefzero/webdav/WebdavClient.java index a1dbd098..fd1ec504 100644 --- a/src/eu/alefzero/webdav/WebdavClient.java +++ b/src/eu/alefzero/webdav/WebdavClient.java @@ -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);