diff --git a/src/com/owncloud/android/datamodel/FileDataStorageManager.java b/src/com/owncloud/android/datamodel/FileDataStorageManager.java index 3adebeeb17..50baf176d3 100644 --- a/src/com/owncloud/android/datamodel/FileDataStorageManager.java +++ b/src/com/owncloud/android/datamodel/FileDataStorageManager.java @@ -108,6 +108,7 @@ public class FileDataStorageManager implements DataStorageManager { boolean overriden = false; ContentValues cv = new ContentValues(); cv.put(ProviderTableMeta.FILE_MODIFIED, file.getModificationTimestamp()); + cv.put(ProviderTableMeta.FILE_MODIFIED_AT_LAST_SYNC_FOR_DATA, file.getModificationTimestampAtLastSyncForData()); cv.put(ProviderTableMeta.FILE_CREATION, file.getCreationTimestamp()); cv.put(ProviderTableMeta.FILE_CONTENT_LENGTH, file.getFileLength()); cv.put(ProviderTableMeta.FILE_CONTENT_TYPE, file.getMimetype()); @@ -189,6 +190,7 @@ public class FileDataStorageManager implements DataStorageManager { file = filesIt.next(); ContentValues cv = new ContentValues(); cv.put(ProviderTableMeta.FILE_MODIFIED, file.getModificationTimestamp()); + cv.put(ProviderTableMeta.FILE_MODIFIED_AT_LAST_SYNC_FOR_DATA, file.getModificationTimestampAtLastSyncForData()); cv.put(ProviderTableMeta.FILE_CREATION, file.getCreationTimestamp()); cv.put(ProviderTableMeta.FILE_CONTENT_LENGTH, file.getFileLength()); cv.put(ProviderTableMeta.FILE_CONTENT_TYPE, file.getMimetype()); @@ -414,6 +416,8 @@ public class FileDataStorageManager implements DataStorageManager { .getColumnIndex(ProviderTableMeta.FILE_CREATION))); file.setModificationTimestamp(c.getLong(c .getColumnIndex(ProviderTableMeta.FILE_MODIFIED))); + file.setModificationTimestampAtLastSyncForData(c.getLong(c + .getColumnIndex(ProviderTableMeta.FILE_MODIFIED_AT_LAST_SYNC_FOR_DATA))); file.setLastSyncDateForProperties(c.getLong(c .getColumnIndex(ProviderTableMeta.FILE_LAST_SYNC_DATE))); file.setLastSyncDateForData(c.getLong(c. diff --git a/src/com/owncloud/android/datamodel/OCFile.java b/src/com/owncloud/android/datamodel/OCFile.java index ec4e749b2a..b1361298d1 100644 --- a/src/com/owncloud/android/datamodel/OCFile.java +++ b/src/com/owncloud/android/datamodel/OCFile.java @@ -47,6 +47,7 @@ public class OCFile implements Parcelable, Comparable { private long mLength; private long mCreationTimestamp; private long mModifiedTimestamp; + private long mModifiedTimestampAtLastSyncForData; private String mRemotePath; private String mLocalPath; private String mMimeType; @@ -84,6 +85,7 @@ public class OCFile implements Parcelable, Comparable { mLength = source.readLong(); mCreationTimestamp = source.readLong(); mModifiedTimestamp = source.readLong(); + mModifiedTimestampAtLastSyncForData = source.readLong(); mRemotePath = source.readString(); mLocalPath = source.readString(); mMimeType = source.readString(); @@ -100,6 +102,7 @@ public class OCFile implements Parcelable, Comparable { dest.writeLong(mLength); dest.writeLong(mCreationTimestamp); dest.writeLong(mModifiedTimestamp); + dest.writeLong(mModifiedTimestampAtLastSyncForData); dest.writeString(mRemotePath); dest.writeString(mLocalPath); dest.writeString(mMimeType); @@ -196,9 +199,10 @@ public class OCFile implements Parcelable, Comparable { } /** - * Get a UNIX timestamp of the file modification time - * - * @return A UNIX timestamp of the modification time + * Get a UNIX timestamp of the file modification time. + * + * @return A UNIX timestamp of the modification time, corresponding to the value returned by the server + * in the last synchronization of the properties of this file. */ public long getModificationTimestamp() { return mModifiedTimestamp; @@ -207,12 +211,40 @@ public class OCFile implements Parcelable, Comparable { /** * Set a UNIX timestamp of the time the time the file was modified. * + * To update with the value returned by the server in every synchronization of the properties + * of this file. + * * @param modification_timestamp to set */ public void setModificationTimestamp(long modification_timestamp) { mModifiedTimestamp = modification_timestamp; } + + /** + * Get a UNIX timestamp of the file modification time. + * + * @return A UNIX timestamp of the modification time, corresponding to the value returned by the server + * in the last synchronization of THE CONTENTS of this file. + */ + public long getModificationTimestampAtLastSyncForData() { + return mModifiedTimestampAtLastSyncForData; + } + + /** + * Set a UNIX timestamp of the time the time the file was modified. + * + * To update with the value returned by the server in every synchronization of THE CONTENTS + * of this file. + * + * @param modification_timestamp to set + */ + public void setModificationTimestampAtLastSyncForData(long modificationTimestamp) { + mModifiedTimestampAtLastSyncForData = modificationTimestamp; + } + + + /** * Returns the filename and "/" for the root directory * @@ -280,6 +312,7 @@ public class OCFile implements Parcelable, Comparable { mLength = 0; mCreationTimestamp = 0; mModifiedTimestamp = 0; + mModifiedTimestampAtLastSyncForData = 0; mLastSyncDateForProperties = 0; mLastSyncDateForData = 0; mKeepInSync = false; diff --git a/src/com/owncloud/android/db/ProviderMeta.java b/src/com/owncloud/android/db/ProviderMeta.java index faa16d7c8e..ffe930b757 100644 --- a/src/com/owncloud/android/db/ProviderMeta.java +++ b/src/com/owncloud/android/db/ProviderMeta.java @@ -31,8 +31,7 @@ public class ProviderMeta { public static final String AUTHORITY_FILES = "org.owncloud"; public static final String DB_FILE = "owncloud.db"; public static final String DB_NAME = "filelist"; - //public static final int DB_VERSION = 2; - public static final int DB_VERSION = 3; + public static final int DB_VERSION = 4; private ProviderMeta() { } @@ -53,6 +52,7 @@ public class ProviderMeta { public static final String FILE_NAME = "filename"; public static final String FILE_CREATION = "created"; public static final String FILE_MODIFIED = "modified"; + public static final String FILE_MODIFIED_AT_LAST_SYNC_FOR_DATA = "modified_at_last_sync_for_data"; public static final String FILE_CONTENT_LENGTH = "content_length"; public static final String FILE_CONTENT_TYPE = "content_type"; public static final String FILE_STORAGE_PATH = "media_path"; diff --git a/src/com/owncloud/android/files/services/FileDownloader.java b/src/com/owncloud/android/files/services/FileDownloader.java index 5e80f5d3b7..b01d61e9c2 100644 --- a/src/com/owncloud/android/files/services/FileDownloader.java +++ b/src/com/owncloud/android/files/services/FileDownloader.java @@ -301,6 +301,7 @@ public class FileDownloader extends Service implements OnDatatransferProgressLis file.setLastSyncDateForProperties(syncDate); file.setLastSyncDateForData(syncDate); file.setModificationTimestamp(mCurrentDownload.getModificationTimestamp()); + file.setModificationTimestampAtLastSyncForData(mCurrentDownload.getModificationTimestamp()); // file.setEtag(mCurrentDownload.getEtag()); // TODO Etag, where available file.setMimetype(mCurrentDownload.getMimeType()); file.setStoragePath(mCurrentDownload.getSavePath()); diff --git a/src/com/owncloud/android/files/services/FileUploader.java b/src/com/owncloud/android/files/services/FileUploader.java index f0afe0d2e2..0887ac1f6b 100644 --- a/src/com/owncloud/android/files/services/FileUploader.java +++ b/src/com/owncloud/android/files/services/FileUploader.java @@ -489,7 +489,8 @@ public class FileUploader extends Service implements OnDatatransferProgressListe file.setCreationTimestamp(we.createTimestamp()); file.setFileLength(we.contentLength()); file.setMimetype(we.contentType()); - file.setModificationTimestamp(we.modifiedTimesamp()); + file.setModificationTimestamp(we.modifiedTimestamp()); + file.setModificationTimestampAtLastSyncForData(we.modifiedTimestamp()); // file.setEtag(mCurrentDownload.getEtag()); // TODO Etag, where available } diff --git a/src/com/owncloud/android/operations/SynchronizeFileOperation.java b/src/com/owncloud/android/operations/SynchronizeFileOperation.java index 312fa0cd60..8bad631b76 100644 --- a/src/com/owncloud/android/operations/SynchronizeFileOperation.java +++ b/src/com/owncloud/android/operations/SynchronizeFileOperation.java @@ -113,7 +113,7 @@ public class SynchronizeFileOperation extends RemoteOperation { serverChanged = (!mServerFile.getEtag().equals(mLocalFile.getEtag())); // TODO could this be dangerous when the user upgrades the server from non-tagged to tagged? } else { // server without etags - serverChanged = (mServerFile.getModificationTimestamp() > mLocalFile.getModificationTimestamp()); + serverChanged = (mServerFile.getModificationTimestamp() > mLocalFile.getModificationTimestampAtLastSyncForData()); } boolean localChanged = (mLocalChangeAlreadyKnown || mLocalFile.getLocalModificationTimestamp() > mLocalFile.getLastSyncDateForData()); // TODO this will be always true after the app is upgraded to database version 3; will result in unnecessary uploads @@ -214,7 +214,7 @@ public class SynchronizeFileOperation extends RemoteOperation { file.setCreationTimestamp(we.createTimestamp()); file.setFileLength(we.contentLength()); file.setMimetype(we.contentType()); - file.setModificationTimestamp(we.modifiedTimesamp()); + file.setModificationTimestamp(we.modifiedTimestamp()); return file; } diff --git a/src/com/owncloud/android/operations/SynchronizeFolderOperation.java b/src/com/owncloud/android/operations/SynchronizeFolderOperation.java index eaf3c3ebcb..151af4bc47 100644 --- a/src/com/owncloud/android/operations/SynchronizeFolderOperation.java +++ b/src/com/owncloud/android/operations/SynchronizeFolderOperation.java @@ -279,7 +279,7 @@ public class SynchronizeFolderOperation extends RemoteOperation { file.setCreationTimestamp(we.createTimestamp()); file.setFileLength(we.contentLength()); file.setMimetype(we.contentType()); - file.setModificationTimestamp(we.modifiedTimesamp()); + file.setModificationTimestamp(we.modifiedTimestamp()); file.setParentId(mParentId); return file; } diff --git a/src/com/owncloud/android/operations/UploadFileOperation.java b/src/com/owncloud/android/operations/UploadFileOperation.java index ac276284fd..fa5bf02c58 100644 --- a/src/com/owncloud/android/operations/UploadFileOperation.java +++ b/src/com/owncloud/android/operations/UploadFileOperation.java @@ -310,6 +310,7 @@ public class UploadFileOperation extends RemoteOperation { newFile.setFileLength(mFile.getFileLength()); newFile.setMimetype(mFile.getMimetype()); newFile.setModificationTimestamp(mFile.getModificationTimestamp()); + newFile.setModificationTimestampAtLastSyncForData(mFile.getModificationTimestampAtLastSyncForData()); // newFile.setEtag(mFile.getEtag()) newFile.setKeepInSync(mFile.keepInSync()); newFile.setLastSyncDateForProperties(mFile.getLastSyncDateForProperties()); diff --git a/src/com/owncloud/android/providers/FileContentProvider.java b/src/com/owncloud/android/providers/FileContentProvider.java index c99616ef4f..5d4f9b8c56 100644 --- a/src/com/owncloud/android/providers/FileContentProvider.java +++ b/src/com/owncloud/android/providers/FileContentProvider.java @@ -62,6 +62,8 @@ public class FileContentProvider extends ContentProvider { ProviderTableMeta.FILE_CREATION); mProjectionMap.put(ProviderTableMeta.FILE_MODIFIED, ProviderTableMeta.FILE_MODIFIED); + mProjectionMap.put(ProviderTableMeta.FILE_MODIFIED_AT_LAST_SYNC_FOR_DATA, + ProviderTableMeta.FILE_MODIFIED_AT_LAST_SYNC_FOR_DATA); mProjectionMap.put(ProviderTableMeta.FILE_CONTENT_LENGTH, ProviderTableMeta.FILE_CONTENT_LENGTH); mProjectionMap.put(ProviderTableMeta.FILE_CONTENT_TYPE, @@ -224,7 +226,8 @@ public class FileContentProvider extends ContentProvider { + ProviderTableMeta.FILE_ACCOUNT_OWNER + " TEXT, " + ProviderTableMeta.FILE_LAST_SYNC_DATE + " INTEGER, " + ProviderTableMeta.FILE_KEEP_IN_SYNC + " INTEGER, " - + ProviderTableMeta.FILE_LAST_SYNC_DATE_FOR_DATA + " INTEGER );" + + ProviderTableMeta.FILE_LAST_SYNC_DATE_FOR_DATA + " INTEGER, " + + ProviderTableMeta.FILE_MODIFIED_AT_LAST_SYNC_FOR_DATA + " INTEGER );" ); } @@ -246,6 +249,13 @@ public class FileContentProvider extends ContentProvider { " DEFAULT 0"); upgraded = true; } + if (oldVersion < 4 && newVersion >= 4) { + Log.i("SQL", "Entering in the #3 ADD in onUpgrade"); + db.execSQL("ALTER TABLE " + ProviderTableMeta.DB_NAME + + " ADD COLUMN " + ProviderTableMeta.FILE_MODIFIED_AT_LAST_SYNC_FOR_DATA + " INTEGER " + + " DEFAULT 0"); + upgraded = true; + } if (!upgraded) Log.i("SQL", "OUT of the ADD in onUpgrade; oldVersion == " + oldVersion + ", newVersion == " + newVersion); } diff --git a/src/eu/alefzero/webdav/WebdavEntry.java b/src/eu/alefzero/webdav/WebdavEntry.java index 5785f91420..30b5660f02 100644 --- a/src/eu/alefzero/webdav/WebdavEntry.java +++ b/src/eu/alefzero/webdav/WebdavEntry.java @@ -126,7 +126,7 @@ public class WebdavEntry { return mCreateTimestamp; } - public long modifiedTimesamp() { + public long modifiedTimestamp() { return mModifiedTimestamp; }