X-Git-Url: http://git.linex4red.de/pub/Android/ownCloud.git/blobdiff_plain/bdc0332c23b326d21193f71ff7db2cf587de0c43..a8fade7369bc8d1752dc4ba5fe07935cac84e96f:/src/com/owncloud/android/operations/DownloadFileOperation.java diff --git a/src/com/owncloud/android/operations/DownloadFileOperation.java b/src/com/owncloud/android/operations/DownloadFileOperation.java index cb4355f5..02098b81 100644 --- a/src/com/owncloud/android/operations/DownloadFileOperation.java +++ b/src/com/owncloud/android/operations/DownloadFileOperation.java @@ -42,7 +42,6 @@ import eu.alefzero.webdav.OnDatatransferProgressListener; import eu.alefzero.webdav.WebdavClient; import eu.alefzero.webdav.WebdavUtils; import android.accounts.Account; -import android.util.Log; import android.webkit.MimeTypeMap; /** @@ -59,6 +58,7 @@ public class DownloadFileOperation extends RemoteOperation { private Set mDataTransferListeners = new HashSet(); private final AtomicBoolean mCancellationRequested = new AtomicBoolean(false); private long mModificationTimestamp = 0; + private GetMethod mGet; public DownloadFileOperation(Account account, OCFile file) { @@ -155,7 +155,7 @@ public class DownloadFileOperation extends RemoteOperation { if (!moved) result = new RemoteOperationResult(RemoteOperationResult.ResultCode.LOCAL_STORAGE_NOT_MOVED); else - result = new RemoteOperationResult(isSuccess(status), status); + result = new RemoteOperationResult(isSuccess(status), status, (mGet != null ? mGet.getResponseHeaders() : null)); Log_OC.i(TAG, "Download of " + mFile.getRemotePath() + " to " + getSavePath() + ": " + result.getLogMessage()); } catch (Exception e) { @@ -175,15 +175,15 @@ public class DownloadFileOperation extends RemoteOperation { protected int downloadFile(WebdavClient client, File targetFile) throws HttpException, IOException, OperationCancelledException { int status = -1; boolean savedFile = false; - GetMethod get = new GetMethod(client.getBaseUri() + WebdavUtils.encodePath(mFile.getRemotePath())); + mGet = new GetMethod(client.getBaseUri() + WebdavUtils.encodePath(mFile.getRemotePath())); Iterator it = null; FileOutputStream fos = null; try { - status = client.executeMethod(get); + status = client.executeMethod(mGet); if (isSuccess(status)) { targetFile.createNewFile(); - BufferedInputStream bis = new BufferedInputStream(get.getResponseBodyAsStream()); + BufferedInputStream bis = new BufferedInputStream(mGet.getResponseBodyAsStream()); fos = new FileOutputStream(targetFile); long transferred = 0; @@ -192,7 +192,7 @@ public class DownloadFileOperation extends RemoteOperation { while ((readResult = bis.read(bytes)) != -1) { synchronized(mCancellationRequested) { if (mCancellationRequested.get()) { - get.abort(); + mGet.abort(); throw new OperationCancelledException(); } } @@ -206,14 +206,14 @@ public class DownloadFileOperation extends RemoteOperation { } } savedFile = true; - Header modificationTime = get.getResponseHeader("Last-Modified"); + Header modificationTime = mGet.getResponseHeader("Last-Modified"); if (modificationTime != null) { Date d = WebdavUtils.parseResponseDate((String) modificationTime.getValue()); mModificationTimestamp = (d != null) ? d.getTime() : 0; } } else { - client.exhaustResponse(get.getResponseBodyAsStream()); + client.exhaustResponse(mGet.getResponseBodyAsStream()); } } finally { @@ -221,7 +221,7 @@ public class DownloadFileOperation extends RemoteOperation { if (!savedFile && targetFile.exists()) { targetFile.delete(); } - get.releaseConnection(); // let the connection available for other methods + mGet.releaseConnection(); // let the connection available for other methods } return status; }