X-Git-Url: http://git.linex4red.de/pub/Android/ownCloud.git/blobdiff_plain/2fcffbd3d580f41ecc114248f4d74a19a34b622b..7d7767aa11b6ed7917a05a13fed6a924d01cbb29:/src/com/owncloud/android/providers/FileContentProvider.java diff --git a/src/com/owncloud/android/providers/FileContentProvider.java b/src/com/owncloud/android/providers/FileContentProvider.java index a4e50cec..9109b548 100644 --- a/src/com/owncloud/android/providers/FileContentProvider.java +++ b/src/com/owncloud/android/providers/FileContentProvider.java @@ -23,7 +23,6 @@ package com.owncloud.android.providers; import java.io.File; -import java.security.Provider; import java.util.ArrayList; import java.util.HashMap; @@ -107,6 +106,8 @@ public class FileContentProvider extends ContentProvider { ProviderTableMeta.FILE_UPDATE_THUMBNAIL); mFileProjectionMap.put(ProviderTableMeta.FILE_IS_DOWNLOADING, ProviderTableMeta.FILE_IS_DOWNLOADING); + mFileProjectionMap.put(ProviderTableMeta.FILE_IN_CONFLICT, + ProviderTableMeta.FILE_IN_CONFLICT); } private static final int SINGLE_FILE = 1; @@ -177,7 +178,6 @@ public class FileContentProvider extends ContentProvider { String remoteId = ""; if (c != null && c.moveToFirst()) { remoteId = c.getString(c.getColumnIndex(ProviderTableMeta.FILE_REMOTE_ID)); - //ThumbnailsCacheManager.removeFileFromCache(remoteId); } Log_OC.d(TAG, "Removing FILE " + remoteId); @@ -525,59 +525,6 @@ public class FileContentProvider extends ContentProvider { } } - /* - private int updateFolderSize(SQLiteDatabase db, String folderId) { - int count = 0; - String [] whereArgs = new String[] { folderId }; - - // read current size saved for the folder - long folderSize = 0; - long folderParentId = -1; - Uri selectFolderUri = Uri.withAppendedPath(ProviderTableMeta.CONTENT_URI_FILE, folderId); - String[] folderProjection = new String[] { ProviderTableMeta.FILE_CONTENT_LENGTH, ProviderTableMeta.FILE_PARENT}; - String folderWhere = ProviderTableMeta._ID + "=?"; - Cursor folderCursor = query(db, selectFolderUri, folderProjection, folderWhere, whereArgs, null); - if (folderCursor != null && folderCursor.moveToFirst()) { - folderSize = folderCursor.getLong(folderCursor.getColumnIndex(ProviderTableMeta.FILE_CONTENT_LENGTH));; - folderParentId = folderCursor.getLong(folderCursor.getColumnIndex(ProviderTableMeta.FILE_PARENT));; - } - folderCursor.close(); - - // read and sum sizes of children - long childrenSize = 0; - Uri selectChildrenUri = Uri.withAppendedPath(ProviderTableMeta.CONTENT_URI_DIR, folderId); - String[] childrenProjection = new String[] { ProviderTableMeta.FILE_CONTENT_LENGTH, ProviderTableMeta.FILE_PARENT}; - String childrenWhere = ProviderTableMeta.FILE_PARENT + "=?"; - Cursor childrenCursor = query(db, selectChildrenUri, childrenProjection, childrenWhere, whereArgs, null); - if (childrenCursor != null && childrenCursor.moveToFirst()) { - while (!childrenCursor.isAfterLast()) { - childrenSize += childrenCursor.getLong(childrenCursor.getColumnIndex(ProviderTableMeta.FILE_CONTENT_LENGTH)); - childrenCursor.moveToNext(); - } - } - childrenCursor.close(); - - // update if needed - if (folderSize != childrenSize) { - Log_OC.d("FileContentProvider", "Updating " + folderSize + " to " + childrenSize); - ContentValues cv = new ContentValues(); - cv.put(ProviderTableMeta.FILE_CONTENT_LENGTH, childrenSize); - count = db.update(ProviderTableMeta.FILE_TABLE_NAME, cv, folderWhere, whereArgs); - - // propagate update until root - if (folderParentId > FileDataStorageManager.ROOT_PARENT_ID) { - Log_OC.d("FileContentProvider", "Propagating update to " + folderParentId); - updateFolderSize(db, String.valueOf(folderParentId)); - } else { - Log_OC.d("FileContentProvider", "NOT propagating to " + folderParentId); - } - } else { - Log_OC.d("FileContentProvider", "NOT updating, sizes are " + folderSize + " and " + childrenSize); - } - return count; - } -*/ - @Override public ContentProviderResult[] applyBatch (ArrayList operations) throws OperationApplicationException { @@ -634,7 +581,8 @@ public class FileContentProvider extends ContentProvider { + ProviderTableMeta.FILE_PERMISSIONS + " TEXT null," + ProviderTableMeta.FILE_REMOTE_ID + " TEXT null," + ProviderTableMeta.FILE_UPDATE_THUMBNAIL + " INTEGER," //boolean - + ProviderTableMeta.FILE_IS_DOWNLOADING + " INTEGER);" //boolean + + ProviderTableMeta.FILE_IS_DOWNLOADING + " INTEGER," //boolean + + ProviderTableMeta.FILE_IN_CONFLICT + " INTEGER);" //boolean ); // Create table ocshares @@ -834,6 +782,24 @@ public class FileContentProvider extends ContentProvider { if (!upgraded) Log_OC.i("SQL", "OUT of the ADD in onUpgrade; oldVersion == " + oldVersion + ", newVersion == " + newVersion); + + if (oldVersion < 11 && newVersion >= 11) { + Log_OC.i("SQL", "Entering in the #11 ADD in onUpgrade"); + db.beginTransaction(); + try { + db .execSQL("ALTER TABLE " + ProviderTableMeta.FILE_TABLE_NAME + + " ADD COLUMN " + ProviderTableMeta.FILE_IN_CONFLICT + " INTEGER " + + " DEFAULT 0"); + upgraded = true; + db.setTransactionSuccessful(); + } finally { + db.endTransaction(); + } + } + if (!upgraded) + Log_OC.i("SQL", "OUT of the ADD in onUpgrade; oldVersion == " + oldVersion + + ", newVersion == " + newVersion); + } }