Merge pull request #6035 from nextcloud/enh/capabilities-etag

Add etag column to capabilities table
This commit is contained in:
Tobias Kaminsky 2020-06-05 07:28:06 +02:00 committed by GitHub
commit d1f17df63c
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
4 changed files with 34 additions and 5 deletions

View file

@ -2078,6 +2078,7 @@ public class FileDataStorageManager {
.getValue());
cv.put(ProviderTableMeta.CAPABILITIES_RICHDOCUMENT_PRODUCT_NAME, capability.getRichDocumentsProductName());
cv.put(ProviderTableMeta.CAPABILITIES_DIRECT_EDITING_ETAG, capability.getDirectEditingEtag());
cv.put(ProviderTableMeta.CAPABILITIES_ETAG, capability.getEtag());
return cv;
}
@ -2198,6 +2199,7 @@ public class FileDataStorageManager {
capability.setRichDocumentsOptionalMimeTypeList(Arrays.asList(optionalMimetypes.split(",")));
capability.setRichDocumentsProductName(getString(c, ProviderTableMeta.CAPABILITIES_RICHDOCUMENT_PRODUCT_NAME));
capability.setDirectEditingEtag(getString(c, ProviderTableMeta.CAPABILITIES_DIRECT_EDITING_ETAG));
capability.setEtag(getString(c, ProviderTableMeta.CAPABILITIES_ETAG));
}
return capability;
}

View file

@ -31,7 +31,7 @@ import com.owncloud.android.MainApp;
*/
public class ProviderMeta {
public static final String DB_NAME = "filelist";
public static final int DB_VERSION = 56;
public static final int DB_VERSION = 57;
private ProviderMeta() {
// No instance
@ -200,6 +200,7 @@ public class ProviderMeta {
public static final String CAPABILITIES_DEFAULT_SORT_ORDER = CAPABILITIES_ACCOUNT_NAME
+ " collate nocase asc";
public static final String CAPABILITIES_DIRECT_EDITING_ETAG = "direct_editing_etag";
public static final String CAPABILITIES_ETAG = "etag";
//Columns of Uploads table
public static final String UPLOADS_LOCAL_PATH = "local_path";

View file

@ -19,6 +19,7 @@
*/
package com.owncloud.android.operations;
import com.owncloud.android.datamodel.FileDataStorageManager;
import com.owncloud.android.lib.common.OwnCloudClient;
import com.owncloud.android.lib.common.operations.RemoteOperationResult;
import com.owncloud.android.lib.resources.status.GetCapabilitiesRemoteOperation;
@ -32,8 +33,14 @@ public class GetCapabilitiesOperation extends SyncOperation {
@Override
protected RemoteOperationResult run(OwnCloudClient client) {
GetCapabilitiesRemoteOperation getCapabilities = new GetCapabilitiesRemoteOperation();
RemoteOperationResult result = getCapabilities.execute(client);
final FileDataStorageManager storageManager = getStorageManager();
OCCapability currentCapability = null;
if (storageManager.getAccount() != null) {
currentCapability = storageManager.getCapability(storageManager.getAccount().name);
}
RemoteOperationResult result = new GetCapabilitiesRemoteOperation(currentCapability).execute(client);
if (result.isSuccess()
&& result.getData() != null && result.getData().size() > 0) {
@ -41,7 +48,7 @@ public class GetCapabilitiesOperation extends SyncOperation {
OCCapability capability = (OCCapability) result.getData().get(0);
// Save the capabilities into database
getStorageManager().saveCapabilities(capability);
storageManager.saveCapabilities(capability);
}
return result;

View file

@ -793,7 +793,8 @@ public class FileContentProvider extends ContentProvider {
+ ProviderTableMeta.CAPABILITIES_RICHDOCUMENT_OPTIONAL_MIMETYPE_LIST + TEXT
+ ProviderTableMeta.CAPABILITIES_SHARING_PUBLIC_ASK_FOR_OPTIONAL_PASSWORD + INTEGER
+ 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) {
@ -2213,6 +2214,24 @@ public class FileContentProvider extends ContentProvider {
if (!upgraded) {
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));
}
}
}
}