mirror of
https://github.com/owncloud/android-library.git
synced 2025-06-07 16:06:08 +00:00
Merge pull request #63 from owncloud/fix_refresh_large_default_storage
Fixed refresh when quota response holds an unexpected value or format
This commit is contained in:
commit
67d800027c
@ -24,6 +24,7 @@
|
||||
|
||||
package com.owncloud.android.lib.common.network;
|
||||
|
||||
import java.math.BigDecimal;
|
||||
import java.util.Date;
|
||||
|
||||
import org.apache.jackrabbit.webdav.MultiStatusResponse;
|
||||
@ -37,6 +38,9 @@ import android.net.Uri;
|
||||
import com.owncloud.android.lib.common.utils.Log_OC;
|
||||
|
||||
public class WebdavEntry {
|
||||
|
||||
private static final String TAG = WebdavEntry.class.getSimpleName();
|
||||
|
||||
public static final String NAMESPACE_OC = "http://owncloud.org/ns";
|
||||
public static final String EXTENDED_PROPERTY_NAME_PERMISSIONS = "permissions";
|
||||
public static final String EXTENDED_PROPERTY_NAME_REMOTE_ID = "id";
|
||||
@ -49,7 +53,7 @@ public class WebdavEntry {
|
||||
|
||||
private String mName, mPath, mUri, mContentType, mEtag, mPermissions, mRemoteId;
|
||||
private long mContentLength, mCreateTimestamp, mModifiedTimestamp, mSize;
|
||||
private long mQuotaUsedBytes, mQuotaAvailableBytes;
|
||||
private BigDecimal mQuotaUsedBytes, mQuotaAvailableBytes;
|
||||
|
||||
public WebdavEntry(MultiStatusResponse ms, String splitElement) {
|
||||
resetData();
|
||||
@ -131,14 +135,27 @@ public class WebdavEntry {
|
||||
// {DAV:}quota-used-bytes
|
||||
prop = propSet.get(DavPropertyName.create(PROPERTY_QUOTA_USED_BYTES));
|
||||
if (prop != null) {
|
||||
mQuotaUsedBytes = Long.parseLong((String) prop.getValue());
|
||||
String quotaUsedBytesSt = (String) prop.getValue();
|
||||
try {
|
||||
mQuotaUsedBytes = new BigDecimal(quotaUsedBytesSt);
|
||||
} catch (NumberFormatException e) {
|
||||
Log_OC.w(TAG, "No value for QuotaUsedBytes");
|
||||
}
|
||||
Log_OC.d(TAG , "QUOTA_USED_BYTES " + quotaUsedBytesSt );
|
||||
}
|
||||
|
||||
// {DAV:}quota-available-bytes
|
||||
prop = propSet.get(DavPropertyName.create(PROPERTY_QUOTA_AVAILABLE_BYTES));
|
||||
if (prop != null) {
|
||||
mQuotaAvailableBytes = Long.parseLong((String) prop.getValue());
|
||||
String quotaAvailableBytesSt = (String) prop.getValue();
|
||||
try {
|
||||
mQuotaAvailableBytes = new BigDecimal(quotaAvailableBytesSt);
|
||||
} catch (NumberFormatException e) {
|
||||
Log_OC.w(TAG, "No value for QuotaAvailableBytes");
|
||||
}
|
||||
Log_OC.d(TAG , "QUOTA_AVAILABLE_BYTES " + quotaAvailableBytesSt );
|
||||
}
|
||||
|
||||
// OC permissions property <oc:permissions>
|
||||
prop = propSet.get(
|
||||
EXTENDED_PROPERTY_NAME_PERMISSIONS, Namespace.getNamespace(NAMESPACE_OC)
|
||||
@ -222,11 +239,11 @@ public class WebdavEntry {
|
||||
return mSize;
|
||||
}
|
||||
|
||||
public long quotaUsedBytes() {
|
||||
public BigDecimal quotaUsedBytes() {
|
||||
return mQuotaUsedBytes;
|
||||
}
|
||||
|
||||
public long quotaAvailableBytes() {
|
||||
public BigDecimal quotaAvailableBytes() {
|
||||
return mQuotaAvailableBytes;
|
||||
}
|
||||
|
||||
@ -234,7 +251,7 @@ public class WebdavEntry {
|
||||
mName = mUri = mContentType = mPermissions = null; mRemoteId = null;
|
||||
mContentLength = mCreateTimestamp = mModifiedTimestamp = 0;
|
||||
mSize = 0;
|
||||
mQuotaUsedBytes = 0;
|
||||
mQuotaAvailableBytes = 0;
|
||||
mQuotaUsedBytes = null;
|
||||
mQuotaAvailableBytes = null;
|
||||
}
|
||||
}
|
||||
|
@ -25,6 +25,7 @@
|
||||
package com.owncloud.android.lib.resources.files;
|
||||
|
||||
import java.io.Serializable;
|
||||
import java.math.BigDecimal;
|
||||
|
||||
import android.os.Parcel;
|
||||
import android.os.Parcelable;
|
||||
@ -51,8 +52,8 @@ public class RemoteFile implements Parcelable, Serializable {
|
||||
private String mPermissions;
|
||||
private String mRemoteId;
|
||||
private long mSize;
|
||||
private long mQuotaUsedBytes;
|
||||
private long mQuotaAvailableBytes;
|
||||
private BigDecimal mQuotaUsedBytes;
|
||||
private BigDecimal mQuotaAvailableBytes;
|
||||
|
||||
/**
|
||||
* Getters and Setters
|
||||
@ -130,11 +131,11 @@ public class RemoteFile implements Parcelable, Serializable {
|
||||
mSize = size;
|
||||
}
|
||||
|
||||
public void setQuotaUsedBytes (long quotaUsedBytes) {
|
||||
public void setQuotaUsedBytes (BigDecimal quotaUsedBytes) {
|
||||
mQuotaUsedBytes = quotaUsedBytes;
|
||||
}
|
||||
|
||||
public void setQuotaAvailableBytes (long quotaAvailableBytes) {
|
||||
public void setQuotaAvailableBytes (BigDecimal quotaAvailableBytes) {
|
||||
mQuotaAvailableBytes = quotaAvailableBytes;
|
||||
}
|
||||
|
||||
@ -184,8 +185,8 @@ public class RemoteFile implements Parcelable, Serializable {
|
||||
mPermissions = null;
|
||||
mRemoteId = null;
|
||||
mSize = 0;
|
||||
mQuotaUsedBytes = 0;
|
||||
mQuotaAvailableBytes = 0;
|
||||
mQuotaUsedBytes = null;
|
||||
mQuotaAvailableBytes = null;
|
||||
}
|
||||
|
||||
/**
|
||||
@ -223,8 +224,8 @@ public class RemoteFile implements Parcelable, Serializable {
|
||||
mPermissions= source.readString();
|
||||
mRemoteId = source.readString();
|
||||
mSize = source.readLong();
|
||||
mQuotaUsedBytes = source.readLong();
|
||||
mQuotaAvailableBytes = source.readLong();
|
||||
mQuotaUsedBytes = (BigDecimal) source.readSerializable();
|
||||
mQuotaAvailableBytes = (BigDecimal) source.readSerializable();
|
||||
}
|
||||
|
||||
@Override
|
||||
@ -243,8 +244,8 @@ public class RemoteFile implements Parcelable, Serializable {
|
||||
dest.writeString(mPermissions);
|
||||
dest.writeString(mRemoteId);
|
||||
dest.writeLong(mSize);
|
||||
dest.writeLong(mQuotaUsedBytes);
|
||||
dest.writeLong(mQuotaAvailableBytes);
|
||||
dest.writeSerializable(mQuotaUsedBytes);
|
||||
dest.writeSerializable(mQuotaAvailableBytes);
|
||||
}
|
||||
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user