mirror of
https://github.com/owncloud/android-library.git
synced 2025-06-08 16:36:13 +00:00
Add capability to reatin ETag value in download operations
This commit is contained in:
parent
522ea30da0
commit
092c790030
@ -61,6 +61,7 @@ public class DownloadRemoteFileOperation extends RemoteOperation {
|
|||||||
private Set<OnDatatransferProgressListener> mDataTransferListeners = new HashSet<OnDatatransferProgressListener>();
|
private Set<OnDatatransferProgressListener> mDataTransferListeners = new HashSet<OnDatatransferProgressListener>();
|
||||||
private final AtomicBoolean mCancellationRequested = new AtomicBoolean(false);
|
private final AtomicBoolean mCancellationRequested = new AtomicBoolean(false);
|
||||||
private long mModificationTimestamp = 0;
|
private long mModificationTimestamp = 0;
|
||||||
|
private String mEtag = "";
|
||||||
private GetMethod mGet;
|
private GetMethod mGet;
|
||||||
|
|
||||||
private String mRemotePath;
|
private String mRemotePath;
|
||||||
@ -146,9 +147,25 @@ public class DownloadRemoteFileOperation extends RemoteOperation {
|
|||||||
if (modificationTime != null) {
|
if (modificationTime != null) {
|
||||||
Date d = WebdavUtils.parseResponseDate((String) modificationTime.getValue());
|
Date d = WebdavUtils.parseResponseDate((String) modificationTime.getValue());
|
||||||
mModificationTimestamp = (d != null) ? d.getTime() : 0;
|
mModificationTimestamp = (d != null) ? d.getTime() : 0;
|
||||||
}
|
} else {
|
||||||
|
Log_OC.e(TAG, "Could not read modification time from response downloading " + mRemotePath);
|
||||||
|
}
|
||||||
|
Header eTag = mGet.getResponseHeader("ETag");
|
||||||
|
if (eTag == null) {
|
||||||
|
eTag = mGet.getResponseHeader("etag");
|
||||||
|
}
|
||||||
|
if (eTag != null) {
|
||||||
|
mEtag = eTag.getValue();
|
||||||
|
if (mEtag.charAt(0) == '"' && mEtag.charAt(mEtag.length() - 1) == '"') {
|
||||||
|
mEtag = mEtag.substring(1, mEtag.length() - 1);
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
Log_OC.e(TAG, "Could not read eTag from response downloading " + mRemotePath);
|
||||||
|
}
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
client.exhaustResponse(mGet.getResponseBodyAsStream());
|
client.exhaustResponse(mGet.getResponseBodyAsStream());
|
||||||
|
// TODO some kind of error control!
|
||||||
}
|
}
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
@ -193,4 +210,7 @@ public class DownloadRemoteFileOperation extends RemoteOperation {
|
|||||||
return mModificationTimestamp;
|
return mModificationTimestamp;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public String getEtag() {
|
||||||
|
return mEtag;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user