Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

persist upload timestamp #13310

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1,215 changes: 1,215 additions & 0 deletions app/schemas/com.nextcloud.client.database.NextcloudDatabase/82.json

Large diffs are not rendered by default.

Original file line number Diff line number Diff line change
Expand Up @@ -452,7 +452,7 @@ public void testCreationAndUploadTimestamp() throws IOException, AccountUtils.Ac

assertEquals(remotePath, ocFile.getRemotePath());
assertEquals(creationTimestamp, ocFile.getCreationTimestamp());
assertTrue(uploadTimestamp - 10 < ocFile.getUploadTimestamp() ||
assertTrue(uploadTimestamp - 10 < ocFile.getUploadTimestamp() &&
uploadTimestamp + 10 > ocFile.getUploadTimestamp());
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@ public class OCFileUnitTest {
private static final String STORAGE_PATH = "/mnt/sd/localpath/to/a/file.txt";
private static final String MIME_TYPE = "text/plain";
private static final long FILE_LENGTH = 9876543210L;
private static final long UPLOADED_TIMESTAMP = 8765431109L;
private static final long CREATION_TIMESTAMP = 8765432109L;
private static final long MODIFICATION_TIMESTAMP = 7654321098L;
private static final long MODIFICATION_TIMESTAMP_AT_LAST_SYNC_FOR_DATA = 6543210987L;
Expand Down Expand Up @@ -63,6 +64,7 @@ public void writeThenReadAsParcelable() {
mFile.setStoragePath(STORAGE_PATH);
mFile.setMimeType(MIME_TYPE);
mFile.setFileLength(FILE_LENGTH);
mFile.setUploadTimestamp(UPLOADED_TIMESTAMP);
mFile.setCreationTimestamp(CREATION_TIMESTAMP);
mFile.setModificationTimestamp(MODIFICATION_TIMESTAMP);
mFile.setModificationTimestampAtLastSyncForData(MODIFICATION_TIMESTAMP_AT_LAST_SYNC_FOR_DATA);
Expand Down Expand Up @@ -93,6 +95,7 @@ public void writeThenReadAsParcelable() {
assertThat(fileReadFromParcel.getStoragePath(), is(STORAGE_PATH));
assertThat(fileReadFromParcel.getMimeType(), is(MIME_TYPE));
assertThat(fileReadFromParcel.getFileLength(), is(FILE_LENGTH));
assertThat(fileReadFromParcel.getUploadTimestamp(), is(UPLOADED_TIMESTAMP));
assertThat(fileReadFromParcel.getCreationTimestamp(), is(CREATION_TIMESTAMP));
assertThat(fileReadFromParcel.getModificationTimestamp(), is(MODIFICATION_TIMESTAMP));
assertThat(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -115,5 +115,7 @@ data class FileEntity(
@ColumnInfo(name = ProviderTableMeta.FILE_METADATA_GPS)
val metadataGPS: String?,
@ColumnInfo(name = ProviderTableMeta.FILE_E2E_COUNTER)
val e2eCounter: Long?
val e2eCounter: Long?,
@ColumnInfo(name = ProviderTableMeta.FILE_UPLOADED)
val uploaded: Long?
)
Original file line number Diff line number Diff line change
Expand Up @@ -526,11 +526,13 @@ public void saveFolder(OCFile folder, List<OCFile> updatedFiles, Collection<OCFi
* @see #createContentValuesForFile(OCFile)
* @see #createContentValuesForFolder(OCFile)
*/
@SuppressFBWarnings("CE")
private ContentValues createContentValuesBase(OCFile fileOrFolder) {
final ContentValues cv = new ContentValues();
cv.put(ProviderTableMeta.FILE_MODIFIED, fileOrFolder.getModificationTimestamp());
cv.put(ProviderTableMeta.FILE_MODIFIED_AT_LAST_SYNC_FOR_DATA, fileOrFolder.getModificationTimestampAtLastSyncForData());
cv.put(ProviderTableMeta.FILE_PARENT, fileOrFolder.getParentId());
cv.put(ProviderTableMeta.FILE_UPLOADED, fileOrFolder.getUploadTimestamp());
cv.put(ProviderTableMeta.FILE_CREATION, fileOrFolder.getCreationTimestamp());
cv.put(ProviderTableMeta.FILE_CONTENT_TYPE, fileOrFolder.getMimeType());
cv.put(ProviderTableMeta.FILE_NAME, fileOrFolder.getFileName());
Expand Down Expand Up @@ -990,6 +992,7 @@ private OCFile createFileInstance(FileEntity fileEntity) {
}
}
ocFile.setFileLength(nullToZero(fileEntity.getContentLength()));
ocFile.setUploadTimestamp(nullToZero(fileEntity.getUploaded()));
ocFile.setCreationTimestamp(nullToZero(fileEntity.getCreation()));
ocFile.setModificationTimestamp(nullToZero(fileEntity.getModified()));
ocFile.setModificationTimestampAtLastSyncForData(nullToZero(fileEntity.getModifiedAtLastSyncForData()));
Expand Down
15 changes: 11 additions & 4 deletions app/src/main/java/com/owncloud/android/datamodel/OCFile.java
Original file line number Diff line number Diff line change
Expand Up @@ -156,6 +156,7 @@ private OCFile(Parcel source) {
fileId = source.readLong();
parentId = source.readLong();
fileLength = source.readLong();
uploadTimestamp = source.readLong();
creationTimestamp = source.readLong();
modificationTimestamp = source.readLong();
modificationTimestampAtLastSyncForData = source.readLong();
Expand Down Expand Up @@ -201,6 +202,7 @@ public void writeToParcel(Parcel dest, int flags) {
dest.writeLong(fileId);
dest.writeLong(parentId);
dest.writeLong(fileLength);
dest.writeLong(uploadTimestamp);
dest.writeLong(creationTimestamp);
dest.writeLong(modificationTimestamp);
dest.writeLong(modificationTimestampAtLastSyncForData);
Expand Down Expand Up @@ -495,6 +497,7 @@ private void resetData() {
localPath = null;
mimeType = null;
fileLength = 0;
uploadTimestamp = 0;
creationTimestamp = 0;
modificationTimestamp = 0;
modificationTimestampAtLastSyncForData = 0;
Expand Down Expand Up @@ -716,10 +719,6 @@ public long getModificationTimestamp() {
return this.modificationTimestamp;
}

public long getUploadTimestamp() {
return this.uploadTimestamp;
}

public long getModificationTimestampAtLastSyncForData() {
return this.modificationTimestampAtLastSyncForData;
}
Expand Down Expand Up @@ -1050,4 +1049,12 @@ public void setE2eCounter(@Nullable Long e2eCounter) {
this.e2eCounter = e2eCounter;
}
}

public long getUploadTimestamp() {
return uploadTimestamp;
}

public void setUploadTimestamp(long uploadTimestamp) {
this.uploadTimestamp = uploadTimestamp;
}
}
4 changes: 3 additions & 1 deletion app/src/main/java/com/owncloud/android/db/ProviderMeta.java
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@
*/
public class ProviderMeta {
public static final String DB_NAME = "filelist";
public static final int DB_VERSION = 81;
public static final int DB_VERSION = 82;

private ProviderMeta() {
// No instance
Expand Down Expand Up @@ -76,6 +76,7 @@ static public class ProviderTableMeta implements BaseColumns {
public static final String FILE_ENCRYPTED_NAME = "encrypted_filename";
public static final String FILE_CREATION = "created";
public static final String FILE_MODIFIED = "modified";
public static final String FILE_UPLOADED = "uploaded";
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";
Expand Down Expand Up @@ -126,6 +127,7 @@ static public class ProviderTableMeta implements BaseColumns {
FILE_PARENT,
FILE_NAME,
FILE_ENCRYPTED_NAME,
FILE_UPLOADED,
FILE_CREATION,
FILE_MODIFIED,
FILE_MODIFIED_AT_LAST_SYNC_FOR_DATA,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -227,6 +227,7 @@ public static OCFile fillOCFile(RemoteFile remote) {
OCFile file = new OCFile(remote.getRemotePath());
file.setDecryptedRemotePath(remote.getRemotePath());
file.setCreationTimestamp(remote.getCreationTimestamp());
file.setUploadTimestamp(remote.getUploadTimestamp());
if (MimeType.DIRECTORY.equalsIgnoreCase(remote.getMimeType())) {
file.setFileLength(remote.getSize());
} else {
Expand Down
Loading