mirror of
https://github.com/nextcloud/android.git
synced 2024-12-18 15:01:57 +03:00
persist upload timestamp
Signed-off-by: tobiasKaminsky <tobias@kaminsky.me>
This commit is contained in:
parent
586a9b8010
commit
8a969e611f
8 changed files with 1332 additions and 7 deletions
1307
app/schemas/com.nextcloud.client.database.NextcloudDatabase/86.json
Normal file
1307
app/schemas/com.nextcloud.client.database.NextcloudDatabase/86.json
Normal file
File diff suppressed because it is too large
Load diff
|
@ -469,7 +469,7 @@ public class UploadIT extends AbstractOnServerIT {
|
|||
|
||||
assertEquals(remotePath, ocFile.getRemotePath());
|
||||
assertEquals(creationTimestamp, ocFile.getCreationTimestamp());
|
||||
assertTrue(uploadTimestamp - 10 < ocFile.getUploadTimestamp() ||
|
||||
assertTrue(uploadTimestamp - 10 < ocFile.getUploadTimestamp() &&
|
||||
uploadTimestamp + 10 > ocFile.getUploadTimestamp());
|
||||
}
|
||||
|
||||
|
|
|
@ -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;
|
||||
|
@ -63,6 +64,7 @@ public class OCFileUnitTest {
|
|||
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);
|
||||
|
@ -93,6 +95,7 @@ public class OCFileUnitTest {
|
|||
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(
|
||||
|
|
|
@ -119,5 +119,7 @@ data class FileEntity(
|
|||
@ColumnInfo(name = ProviderTableMeta.FILE_INTERNAL_TWO_WAY_SYNC_TIMESTAMP)
|
||||
val internalTwoWaySync: Long?,
|
||||
@ColumnInfo(name = ProviderTableMeta.FILE_INTERNAL_TWO_WAY_SYNC_RESULT)
|
||||
val internalTwoWaySyncResult: String?
|
||||
val internalTwoWaySyncResult: String?,
|
||||
@ColumnInfo(name = ProviderTableMeta.FILE_UPLOADED)
|
||||
val uploaded: Long?
|
||||
)
|
||||
|
|
|
@ -729,11 +729,13 @@ public class FileDataStorageManager {
|
|||
* @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());
|
||||
|
@ -1203,6 +1205,7 @@ public class FileDataStorageManager {
|
|||
}
|
||||
}
|
||||
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()));
|
||||
|
|
|
@ -161,6 +161,7 @@ public class OCFile implements Parcelable, Comparable<OCFile>, ServerFileInterfa
|
|||
fileId = source.readLong();
|
||||
parentId = source.readLong();
|
||||
fileLength = source.readLong();
|
||||
uploadTimestamp = source.readLong();
|
||||
creationTimestamp = source.readLong();
|
||||
modificationTimestamp = source.readLong();
|
||||
modificationTimestampAtLastSyncForData = source.readLong();
|
||||
|
@ -206,6 +207,7 @@ public class OCFile implements Parcelable, Comparable<OCFile>, ServerFileInterfa
|
|||
dest.writeLong(fileId);
|
||||
dest.writeLong(parentId);
|
||||
dest.writeLong(fileLength);
|
||||
dest.writeLong(uploadTimestamp);
|
||||
dest.writeLong(creationTimestamp);
|
||||
dest.writeLong(modificationTimestamp);
|
||||
dest.writeLong(modificationTimestampAtLastSyncForData);
|
||||
|
@ -500,6 +502,7 @@ public class OCFile implements Parcelable, Comparable<OCFile>, ServerFileInterfa
|
|||
localPath = null;
|
||||
mimeType = null;
|
||||
fileLength = 0;
|
||||
uploadTimestamp = 0;
|
||||
creationTimestamp = 0;
|
||||
modificationTimestamp = 0;
|
||||
modificationTimestampAtLastSyncForData = 0;
|
||||
|
@ -721,10 +724,6 @@ public class OCFile implements Parcelable, Comparable<OCFile>, ServerFileInterfa
|
|||
return this.modificationTimestamp;
|
||||
}
|
||||
|
||||
public long getUploadTimestamp() {
|
||||
return this.uploadTimestamp;
|
||||
}
|
||||
|
||||
public long getModificationTimestampAtLastSyncForData() {
|
||||
return this.modificationTimestampAtLastSyncForData;
|
||||
}
|
||||
|
@ -1099,4 +1098,12 @@ public class OCFile implements Parcelable, Comparable<OCFile>, ServerFileInterfa
|
|||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
public long getUploadTimestamp() {
|
||||
return uploadTimestamp;
|
||||
}
|
||||
|
||||
public void setUploadTimestamp(long uploadTimestamp) {
|
||||
this.uploadTimestamp = uploadTimestamp;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -25,7 +25,7 @@ import java.util.List;
|
|||
*/
|
||||
public class ProviderMeta {
|
||||
public static final String DB_NAME = "filelist";
|
||||
public static final int DB_VERSION = 85;
|
||||
public static final int DB_VERSION = 86;
|
||||
|
||||
private ProviderMeta() {
|
||||
// No instance
|
||||
|
@ -77,6 +77,7 @@ public class ProviderMeta {
|
|||
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";
|
||||
|
@ -129,6 +130,7 @@ public class ProviderMeta {
|
|||
FILE_PARENT,
|
||||
FILE_NAME,
|
||||
FILE_ENCRYPTED_NAME,
|
||||
FILE_UPLOADED,
|
||||
FILE_CREATION,
|
||||
FILE_MODIFIED,
|
||||
FILE_MODIFIED_AT_LAST_SYNC_FOR_DATA,
|
||||
|
|
|
@ -227,6 +227,7 @@ public final class FileStorageUtils {
|
|||
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 {
|
||||
|
|
Loading…
Reference in a new issue