diff --git a/src/com/owncloud/android/datamodel/FileDataStorageManager.java b/src/com/owncloud/android/datamodel/FileDataStorageManager.java index 2f2cf453d7..c8c0d24d5a 100644 --- a/src/com/owncloud/android/datamodel/FileDataStorageManager.java +++ b/src/com/owncloud/android/datamodel/FileDataStorageManager.java @@ -187,6 +187,7 @@ public class FileDataStorageManager { cv.put(ProviderTableMeta.FILE_SHARE_BY_LINK, file.isShareByLink() ? 1 : 0); cv.put(ProviderTableMeta.FILE_PUBLIC_LINK, file.getPublicLink()); cv.put(ProviderTableMeta.FILE_PERMISSIONS, file.getPermissions()); + cv.put(ProviderTableMeta.FILE_REMOTE_ID, file.getRemoteId()); boolean sameRemotePath = fileExists(file.getRemotePath()); if (sameRemotePath || @@ -287,6 +288,7 @@ public class FileDataStorageManager { cv.put(ProviderTableMeta.FILE_SHARE_BY_LINK, file.isShareByLink() ? 1 : 0); cv.put(ProviderTableMeta.FILE_PUBLIC_LINK, file.getPublicLink()); cv.put(ProviderTableMeta.FILE_PERMISSIONS, file.getPermissions()); + cv.put(ProviderTableMeta.FILE_REMOTE_ID, file.getRemoteId()); boolean existsByPath = fileExists(file.getRemotePath()); if (existsByPath || fileExists(file.getFileId())) { @@ -345,6 +347,7 @@ public class FileDataStorageManager { cv.put(ProviderTableMeta.FILE_SHARE_BY_LINK, folder.isShareByLink() ? 1 : 0); cv.put(ProviderTableMeta.FILE_PUBLIC_LINK, folder.getPublicLink()); cv.put(ProviderTableMeta.FILE_PERMISSIONS, folder.getPermissions()); + cv.put(ProviderTableMeta.FILE_REMOTE_ID, folder.getRemoteId()); operations.add(ContentProviderOperation.newUpdate(ProviderTableMeta.CONTENT_URI). withValues(cv). @@ -754,6 +757,7 @@ public class FileDataStorageManager { c.getColumnIndex(ProviderTableMeta.FILE_SHARE_BY_LINK)) == 1 ? true : false); file.setPublicLink(c.getString(c.getColumnIndex(ProviderTableMeta.FILE_PUBLIC_LINK))); file.setPermissions(c.getString(c.getColumnIndex(ProviderTableMeta.FILE_PERMISSIONS))); + file.setRemoteId(c.getString(c.getColumnIndex(ProviderTableMeta.FILE_REMOTE_ID))); } return file; @@ -1097,6 +1101,7 @@ public class FileDataStorageManager { cv.put(ProviderTableMeta.FILE_SHARE_BY_LINK, file.isShareByLink() ? 1 : 0); cv.put(ProviderTableMeta.FILE_PUBLIC_LINK, file.getPublicLink()); cv.put(ProviderTableMeta.FILE_PERMISSIONS, file.getPermissions()); + cv.put(ProviderTableMeta.FILE_REMOTE_ID, file.getRemoteId()); boolean existsByPath = fileExists(file.getRemotePath()); if (existsByPath || fileExists(file.getFileId())) { diff --git a/src/com/owncloud/android/datamodel/OCFile.java b/src/com/owncloud/android/datamodel/OCFile.java index ae2376dbe2..92168ff5c7 100644 --- a/src/com/owncloud/android/datamodel/OCFile.java +++ b/src/com/owncloud/android/datamodel/OCFile.java @@ -66,6 +66,7 @@ public class OCFile implements Parcelable, Comparable { private String mPublicLink; private String mPermissions; + private String mRemoteId; /** @@ -107,6 +108,7 @@ public class OCFile implements Parcelable, Comparable { mShareByLink = source.readInt() == 1; mPublicLink = source.readString(); mPermissions = source.readString(); + mRemoteId = source.readString(); } @Override @@ -128,6 +130,7 @@ public class OCFile implements Parcelable, Comparable { dest.writeInt(mShareByLink ? 1 : 0); dest.writeString(mPublicLink); dest.writeString(mPermissions); + dest.writeString(mRemoteId); } /** @@ -339,6 +342,7 @@ public class OCFile implements Parcelable, Comparable { mShareByLink = false; mPublicLink = null; mPermissions = null; + mRemoteId = null; } /** @@ -531,4 +535,12 @@ public class OCFile implements Parcelable, Comparable { this.mPermissions = permissions; } + public String getRemoteId() { + return mRemoteId; + } + + public void setRemoteId(String remoteId) { + this.mRemoteId = remoteId; + } + } diff --git a/src/com/owncloud/android/db/ProviderMeta.java b/src/com/owncloud/android/db/ProviderMeta.java index 6f9683c307..f99734c55a 100644 --- a/src/com/owncloud/android/db/ProviderMeta.java +++ b/src/com/owncloud/android/db/ProviderMeta.java @@ -69,6 +69,7 @@ public class ProviderMeta { public static final String FILE_SHARE_BY_LINK = "share_by_link"; public static final String FILE_PUBLIC_LINK = "public_link"; public static final String FILE_PERMISSIONS = "permissions"; + public static final String FILE_REMOTE_ID = "remote_id"; public static final String FILE_DEFAULT_SORT_ORDER = FILE_NAME + " collate nocase asc"; diff --git a/src/com/owncloud/android/operations/SynchronizeFolderOperation.java b/src/com/owncloud/android/operations/SynchronizeFolderOperation.java index a665d570aa..fc4a74e857 100644 --- a/src/com/owncloud/android/operations/SynchronizeFolderOperation.java +++ b/src/com/owncloud/android/operations/SynchronizeFolderOperation.java @@ -417,6 +417,7 @@ public class SynchronizeFolderOperation extends RemoteOperation { file.setModificationTimestamp(remote.getModifiedTimestamp()); file.setEtag(remote.getEtag()); file.setPermissions(remote.getPermissions()); + file.setRemoteId(remote.getRemoteId()); return file; } diff --git a/src/com/owncloud/android/providers/FileContentProvider.java b/src/com/owncloud/android/providers/FileContentProvider.java index 22bcc1e40b..8ef44e37ae 100644 --- a/src/com/owncloud/android/providers/FileContentProvider.java +++ b/src/com/owncloud/android/providers/FileContentProvider.java @@ -95,6 +95,8 @@ public class FileContentProvider extends ContentProvider { ProviderTableMeta.FILE_PUBLIC_LINK); mFileProjectionMap.put(ProviderTableMeta.FILE_PERMISSIONS, ProviderTableMeta.FILE_PERMISSIONS); + mFileProjectionMap.put(ProviderTableMeta.FILE_REMOTE_ID, + ProviderTableMeta.FILE_REMOTE_ID); } private static final int SINGLE_FILE = 1; @@ -557,7 +559,8 @@ public class FileContentProvider extends ContentProvider { + ProviderTableMeta.FILE_ETAG + " TEXT, " + ProviderTableMeta.FILE_SHARE_BY_LINK + " INTEGER, " + ProviderTableMeta.FILE_PUBLIC_LINK + " TEXT, " - + ProviderTableMeta.FILE_PERMISSIONS + " TEXT null);" + + ProviderTableMeta.FILE_PERMISSIONS + " TEXT null," + + ProviderTableMeta.FILE_REMOTE_ID + " TEXT null);" ); // Create table ocshares @@ -646,7 +649,7 @@ public class FileContentProvider extends ContentProvider { } if (!upgraded) Log_OC.i("SQL", "OUT of the ADD in onUpgrade; oldVersion == " + oldVersion + ", newVersion == " + newVersion); - + if (oldVersion < 6 && newVersion >= 6) { Log_OC.i("SQL", "Entering in the #5 ADD in onUpgrade"); db.beginTransaction(); @@ -658,10 +661,6 @@ public class FileContentProvider extends ContentProvider { db .execSQL("ALTER TABLE " + ProviderTableMeta.FILE_TABLE_NAME + " ADD COLUMN " + ProviderTableMeta.FILE_PUBLIC_LINK + " TEXT " + " DEFAULT NULL"); - - db .execSQL("ALTER TABLE " + ProviderTableMeta.FILE_TABLE_NAME + - " ADD COLUMN " + ProviderTableMeta.FILE_PERMISSIONS + " TEXT " + - " DEFAULT NULL"); // Create table ocshares db.execSQL("CREATE TABLE " + ProviderTableMeta.OCSHARES_TABLE_NAME + "(" @@ -680,6 +679,27 @@ public class FileContentProvider extends ContentProvider { + ProviderTableMeta.OCSHARES_USER_ID + " INTEGER, " + ProviderTableMeta.OCSHARES_ID_REMOTE_SHARED + " INTEGER," + ProviderTableMeta.OCSHARES_ACCOUNT_OWNER + " TEXT );" ); + + upgraded = true; + db.setTransactionSuccessful(); + } finally { + db.endTransaction(); + } + } + if (!upgraded) + Log_OC.i("SQL", "OUT of the ADD in onUpgrade; oldVersion == " + oldVersion + ", newVersion == " + newVersion); + + if (oldVersion < 7 && newVersion >= 7) { + Log_OC.i("SQL", "Entering in the #6 ADD in onUpgrade"); + db.beginTransaction(); + try { + db .execSQL("ALTER TABLE " + ProviderTableMeta.FILE_TABLE_NAME + + " ADD COLUMN " + ProviderTableMeta.FILE_PERMISSIONS + " TEXT " + + " DEFAULT NULL"); + + db .execSQL("ALTER TABLE " + ProviderTableMeta.FILE_REMOTE_ID + + " ADD COLUMN " + ProviderTableMeta.FILE_REMOTE_ID + " TEXT " + + " DEFAULT NULL"); upgraded = true; db.setTransactionSuccessful(); diff --git a/src/com/owncloud/android/utils/FileStorageUtils.java b/src/com/owncloud/android/utils/FileStorageUtils.java index 2bf05545fb..58dda0daf2 100644 --- a/src/com/owncloud/android/utils/FileStorageUtils.java +++ b/src/com/owncloud/android/utils/FileStorageUtils.java @@ -98,6 +98,7 @@ public class FileStorageUtils { file.setModificationTimestamp(remote.getModifiedTimestamp()); file.setEtag(remote.getEtag()); file.setPermissions(remote.getPermissions()); + file.setRemoteId(remote.getRemoteId()); return file; } @@ -115,6 +116,7 @@ public class FileStorageUtils { file.setModifiedTimestamp(ocFile.getModificationTimestamp()); file.setEtag(ocFile.getEtag()); file.setPermissions(ocFile.getPermissions()); + file.setRemoteId(ocFile.getRemoteId()); return file; }