mirror of
https://github.com/owncloud/android-library.git
synced 2025-06-08 00:16:09 +00:00
Prevent conditional update of remote avatar to work around bug breaking refesh of root folder
This commit is contained in:
parent
5ff9062ea8
commit
b87d2c9e7c
@ -28,6 +28,7 @@ package com.owncloud.android.lib.resources.users;
|
|||||||
|
|
||||||
import java.io.BufferedInputStream;
|
import java.io.BufferedInputStream;
|
||||||
import java.io.ByteArrayOutputStream;
|
import java.io.ByteArrayOutputStream;
|
||||||
|
import java.io.IOException;
|
||||||
import java.io.InputStream;
|
import java.io.InputStream;
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
|
|
||||||
@ -73,6 +74,8 @@ public class GetRemoteUserAvatarOperation extends RemoteOperation {
|
|||||||
RemoteOperationResult result = null;
|
RemoteOperationResult result = null;
|
||||||
GetMethod get = null;
|
GetMethod get = null;
|
||||||
InputStream inputStream = null;
|
InputStream inputStream = null;
|
||||||
|
BufferedInputStream bis = null;
|
||||||
|
ByteArrayOutputStream bos = null;
|
||||||
|
|
||||||
try {
|
try {
|
||||||
String uri =
|
String uri =
|
||||||
@ -81,9 +84,19 @@ public class GetRemoteUserAvatarOperation extends RemoteOperation {
|
|||||||
;
|
;
|
||||||
Log_OC.d(TAG, "avatar URI: " + uri);
|
Log_OC.d(TAG, "avatar URI: " + uri);
|
||||||
get = new GetMethod(uri);
|
get = new GetMethod(uri);
|
||||||
|
/* Conditioned call is corrupting the input stream of the connection.
|
||||||
|
Seems that response with 304 is also including the avatar in the response body,
|
||||||
|
though it's forbidden by HTTPS specification. Besides, HTTPClient library
|
||||||
|
assumes there is nothing in the response body, but the bytes are read
|
||||||
|
by the next request, resulting in an exception due to a corrupt status line
|
||||||
|
|
||||||
|
Maybe when we have a real API we can enable this again.
|
||||||
|
|
||||||
if (mCurrentEtag != null && mCurrentEtag.length() > 0) {
|
if (mCurrentEtag != null && mCurrentEtag.length() > 0) {
|
||||||
get.addRequestHeader(IF_NONE_MATCH_HEADER, "\"" + mCurrentEtag + "\"");
|
get.addRequestHeader(IF_NONE_MATCH_HEADER, "\"" + mCurrentEtag + "\"");
|
||||||
}
|
}
|
||||||
|
*/
|
||||||
|
|
||||||
//get.addRequestHeader(OCS_API_HEADER, OCS_API_HEADER_VALUE);
|
//get.addRequestHeader(OCS_API_HEADER, OCS_API_HEADER_VALUE);
|
||||||
int status = client.executeMethod(get);
|
int status = client.executeMethod(get);
|
||||||
if (isSuccess(status)) {
|
if (isSuccess(status)) {
|
||||||
@ -111,8 +124,8 @@ public class GetRemoteUserAvatarOperation extends RemoteOperation {
|
|||||||
|
|
||||||
/// download will be performed to a buffer
|
/// download will be performed to a buffer
|
||||||
inputStream = get.getResponseBodyAsStream();
|
inputStream = get.getResponseBodyAsStream();
|
||||||
BufferedInputStream bis = new BufferedInputStream(inputStream);
|
bis = new BufferedInputStream(inputStream);
|
||||||
ByteArrayOutputStream bos = new ByteArrayOutputStream(totalToTransfer);
|
bos = new ByteArrayOutputStream(totalToTransfer);
|
||||||
|
|
||||||
long transferred = 0;
|
long transferred = 0;
|
||||||
byte[] bytes = new byte[4096];
|
byte[] bytes = new byte[4096];
|
||||||
@ -147,8 +160,24 @@ public class GetRemoteUserAvatarOperation extends RemoteOperation {
|
|||||||
|
|
||||||
} finally {
|
} finally {
|
||||||
if (get != null) {
|
if (get != null) {
|
||||||
|
try {
|
||||||
if (inputStream != null) {
|
if (inputStream != null) {
|
||||||
client.exhaustResponse(inputStream);
|
client.exhaustResponse(inputStream);
|
||||||
|
if (bis != null) {
|
||||||
|
bis.close();
|
||||||
|
} else {
|
||||||
|
inputStream.close();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
} catch (IOException i) {
|
||||||
|
Log_OC.e(TAG, "Unexpected exception closing input stream ", i);
|
||||||
|
}
|
||||||
|
try {
|
||||||
|
if (bos != null) {
|
||||||
|
bos.close();
|
||||||
|
}
|
||||||
|
} catch (IOException o) {
|
||||||
|
Log_OC.e(TAG, "Unexpected exception closing output stream ", o);
|
||||||
}
|
}
|
||||||
get.releaseConnection();
|
get.releaseConnection();
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user