mirror of
https://github.com/nextcloud/android.git
synced 2024-11-22 05:05:31 +03:00
Merge pull request #6035 from nextcloud/enh/capabilities-etag
Add etag column to capabilities table
This commit is contained in:
commit
d1f17df63c
4 changed files with 34 additions and 5 deletions
|
@ -2078,6 +2078,7 @@ public class FileDataStorageManager {
|
||||||
.getValue());
|
.getValue());
|
||||||
cv.put(ProviderTableMeta.CAPABILITIES_RICHDOCUMENT_PRODUCT_NAME, capability.getRichDocumentsProductName());
|
cv.put(ProviderTableMeta.CAPABILITIES_RICHDOCUMENT_PRODUCT_NAME, capability.getRichDocumentsProductName());
|
||||||
cv.put(ProviderTableMeta.CAPABILITIES_DIRECT_EDITING_ETAG, capability.getDirectEditingEtag());
|
cv.put(ProviderTableMeta.CAPABILITIES_DIRECT_EDITING_ETAG, capability.getDirectEditingEtag());
|
||||||
|
cv.put(ProviderTableMeta.CAPABILITIES_ETAG, capability.getEtag());
|
||||||
|
|
||||||
return cv;
|
return cv;
|
||||||
}
|
}
|
||||||
|
@ -2198,6 +2199,7 @@ public class FileDataStorageManager {
|
||||||
capability.setRichDocumentsOptionalMimeTypeList(Arrays.asList(optionalMimetypes.split(",")));
|
capability.setRichDocumentsOptionalMimeTypeList(Arrays.asList(optionalMimetypes.split(",")));
|
||||||
capability.setRichDocumentsProductName(getString(c, ProviderTableMeta.CAPABILITIES_RICHDOCUMENT_PRODUCT_NAME));
|
capability.setRichDocumentsProductName(getString(c, ProviderTableMeta.CAPABILITIES_RICHDOCUMENT_PRODUCT_NAME));
|
||||||
capability.setDirectEditingEtag(getString(c, ProviderTableMeta.CAPABILITIES_DIRECT_EDITING_ETAG));
|
capability.setDirectEditingEtag(getString(c, ProviderTableMeta.CAPABILITIES_DIRECT_EDITING_ETAG));
|
||||||
|
capability.setEtag(getString(c, ProviderTableMeta.CAPABILITIES_ETAG));
|
||||||
}
|
}
|
||||||
return capability;
|
return capability;
|
||||||
}
|
}
|
||||||
|
|
|
@ -31,7 +31,7 @@ import com.owncloud.android.MainApp;
|
||||||
*/
|
*/
|
||||||
public class ProviderMeta {
|
public class ProviderMeta {
|
||||||
public static final String DB_NAME = "filelist";
|
public static final String DB_NAME = "filelist";
|
||||||
public static final int DB_VERSION = 56;
|
public static final int DB_VERSION = 57;
|
||||||
|
|
||||||
private ProviderMeta() {
|
private ProviderMeta() {
|
||||||
// No instance
|
// No instance
|
||||||
|
@ -200,6 +200,7 @@ public class ProviderMeta {
|
||||||
public static final String CAPABILITIES_DEFAULT_SORT_ORDER = CAPABILITIES_ACCOUNT_NAME
|
public static final String CAPABILITIES_DEFAULT_SORT_ORDER = CAPABILITIES_ACCOUNT_NAME
|
||||||
+ " collate nocase asc";
|
+ " collate nocase asc";
|
||||||
public static final String CAPABILITIES_DIRECT_EDITING_ETAG = "direct_editing_etag";
|
public static final String CAPABILITIES_DIRECT_EDITING_ETAG = "direct_editing_etag";
|
||||||
|
public static final String CAPABILITIES_ETAG = "etag";
|
||||||
|
|
||||||
//Columns of Uploads table
|
//Columns of Uploads table
|
||||||
public static final String UPLOADS_LOCAL_PATH = "local_path";
|
public static final String UPLOADS_LOCAL_PATH = "local_path";
|
||||||
|
|
|
@ -19,6 +19,7 @@
|
||||||
*/
|
*/
|
||||||
package com.owncloud.android.operations;
|
package com.owncloud.android.operations;
|
||||||
|
|
||||||
|
import com.owncloud.android.datamodel.FileDataStorageManager;
|
||||||
import com.owncloud.android.lib.common.OwnCloudClient;
|
import com.owncloud.android.lib.common.OwnCloudClient;
|
||||||
import com.owncloud.android.lib.common.operations.RemoteOperationResult;
|
import com.owncloud.android.lib.common.operations.RemoteOperationResult;
|
||||||
import com.owncloud.android.lib.resources.status.GetCapabilitiesRemoteOperation;
|
import com.owncloud.android.lib.resources.status.GetCapabilitiesRemoteOperation;
|
||||||
|
@ -32,8 +33,14 @@ public class GetCapabilitiesOperation extends SyncOperation {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected RemoteOperationResult run(OwnCloudClient client) {
|
protected RemoteOperationResult run(OwnCloudClient client) {
|
||||||
GetCapabilitiesRemoteOperation getCapabilities = new GetCapabilitiesRemoteOperation();
|
final FileDataStorageManager storageManager = getStorageManager();
|
||||||
RemoteOperationResult result = getCapabilities.execute(client);
|
|
||||||
|
OCCapability currentCapability = null;
|
||||||
|
if (storageManager.getAccount() != null) {
|
||||||
|
currentCapability = storageManager.getCapability(storageManager.getAccount().name);
|
||||||
|
}
|
||||||
|
|
||||||
|
RemoteOperationResult result = new GetCapabilitiesRemoteOperation(currentCapability).execute(client);
|
||||||
|
|
||||||
if (result.isSuccess()
|
if (result.isSuccess()
|
||||||
&& result.getData() != null && result.getData().size() > 0) {
|
&& result.getData() != null && result.getData().size() > 0) {
|
||||||
|
@ -41,7 +48,7 @@ public class GetCapabilitiesOperation extends SyncOperation {
|
||||||
OCCapability capability = (OCCapability) result.getData().get(0);
|
OCCapability capability = (OCCapability) result.getData().get(0);
|
||||||
|
|
||||||
// Save the capabilities into database
|
// Save the capabilities into database
|
||||||
getStorageManager().saveCapabilities(capability);
|
storageManager.saveCapabilities(capability);
|
||||||
}
|
}
|
||||||
|
|
||||||
return result;
|
return result;
|
||||||
|
|
|
@ -793,7 +793,8 @@ public class FileContentProvider extends ContentProvider {
|
||||||
+ ProviderTableMeta.CAPABILITIES_RICHDOCUMENT_OPTIONAL_MIMETYPE_LIST + TEXT
|
+ ProviderTableMeta.CAPABILITIES_RICHDOCUMENT_OPTIONAL_MIMETYPE_LIST + TEXT
|
||||||
+ ProviderTableMeta.CAPABILITIES_SHARING_PUBLIC_ASK_FOR_OPTIONAL_PASSWORD + INTEGER
|
+ ProviderTableMeta.CAPABILITIES_SHARING_PUBLIC_ASK_FOR_OPTIONAL_PASSWORD + INTEGER
|
||||||
+ ProviderTableMeta.CAPABILITIES_RICHDOCUMENT_PRODUCT_NAME + TEXT
|
+ ProviderTableMeta.CAPABILITIES_RICHDOCUMENT_PRODUCT_NAME + TEXT
|
||||||
+ ProviderTableMeta.CAPABILITIES_DIRECT_EDITING_ETAG + " TEXT );");
|
+ ProviderTableMeta.CAPABILITIES_DIRECT_EDITING_ETAG + TEXT
|
||||||
|
+ ProviderTableMeta.CAPABILITIES_ETAG + " TEXT );");
|
||||||
}
|
}
|
||||||
|
|
||||||
private void createUploadsTable(SQLiteDatabase db) {
|
private void createUploadsTable(SQLiteDatabase db) {
|
||||||
|
@ -2213,6 +2214,24 @@ public class FileContentProvider extends ContentProvider {
|
||||||
if (!upgraded) {
|
if (!upgraded) {
|
||||||
Log_OC.i(SQL, String.format(Locale.ENGLISH, UPGRADE_VERSION_MSG, oldVersion, newVersion));
|
Log_OC.i(SQL, String.format(Locale.ENGLISH, UPGRADE_VERSION_MSG, oldVersion, newVersion));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (oldVersion < 57 && newVersion >= 57) {
|
||||||
|
Log_OC.i(SQL, "Entering in the #57 add etag for capabilities");
|
||||||
|
db.beginTransaction();
|
||||||
|
try {
|
||||||
|
db.execSQL(ALTER_TABLE + ProviderTableMeta.CAPABILITIES_TABLE_NAME +
|
||||||
|
ADD_COLUMN + ProviderTableMeta.CAPABILITIES_ETAG + " TEXT ");
|
||||||
|
|
||||||
|
upgraded = true;
|
||||||
|
db.setTransactionSuccessful();
|
||||||
|
} finally {
|
||||||
|
db.endTransaction();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!upgraded) {
|
||||||
|
Log_OC.i(SQL, String.format(Locale.ENGLISH, UPGRADE_VERSION_MSG, oldVersion, newVersion));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue