mirror of https://github.com/M66B/FairEmail.git
Store and check uid validity
This commit is contained in:
parent
ab50d9db77
commit
861c6da4b9
File diff suppressed because it is too large
Load Diff
|
@ -985,6 +985,19 @@ class Core {
|
|||
|
||||
db.folder().setFolderSyncState(folder.id, "syncing");
|
||||
|
||||
// Check uid validity
|
||||
try {
|
||||
long uidv = ifolder.getUIDValidity();
|
||||
if (folder.uidv != null && folder.uidv.equals(uidv)) {
|
||||
Log.w(folder.name + " uid validity changed from " + folder.uidv + " to " + uidv);
|
||||
db.message().deleteLocalMessages(folder.id);
|
||||
}
|
||||
folder.uidv = uidv;
|
||||
db.folder().setFolderUidValidity(folder.id, uidv);
|
||||
} catch (MessagingException ex) {
|
||||
Log.w(ex);
|
||||
}
|
||||
|
||||
// Get reference times
|
||||
Calendar cal_sync = Calendar.getInstance();
|
||||
cal_sync.add(Calendar.DAY_OF_MONTH, -sync_days);
|
||||
|
|
|
@ -57,7 +57,7 @@ import io.requery.android.database.sqlite.RequerySQLiteOpenHelperFactory;
|
|||
// https://developer.android.com/topic/libraries/architecture/room.html
|
||||
|
||||
@Database(
|
||||
version = 96,
|
||||
version = 97,
|
||||
entities = {
|
||||
EntityIdentity.class,
|
||||
EntityAccount.class,
|
||||
|
@ -977,6 +977,13 @@ public abstract class DB extends RoomDatabase {
|
|||
" (SELECT COUNT(attachment.id) FROM attachment WHERE attachment.message = message.id)");
|
||||
}
|
||||
})
|
||||
.addMigrations(new Migration(96, 97) {
|
||||
@Override
|
||||
public void migrate(@NonNull SupportSQLiteDatabase db) {
|
||||
Log.i("DB migration from version " + startVersion + " to " + endVersion);
|
||||
db.execSQL("ALTER TABLE `folder` ADD COLUMN `uidv` INTEGER");
|
||||
}
|
||||
})
|
||||
.build();
|
||||
}
|
||||
|
||||
|
|
|
@ -278,6 +278,9 @@ public interface DaoFolder {
|
|||
@Query("UPDATE folder SET keep_days = :days WHERE id = :id")
|
||||
int setFolderKeep(long id, int days);
|
||||
|
||||
@Query("UPDATE folder SET uidv = :uidv WHERE id = :id")
|
||||
int setFolderUidValidity(long id, Long uidv);
|
||||
|
||||
@Query("UPDATE folder SET last_sync = :last_sync WHERE id = :id")
|
||||
int setFolderSync(long id, long last_sync);
|
||||
|
||||
|
|
|
@ -64,6 +64,7 @@ public class EntityFolder extends EntityOrder implements Serializable {
|
|||
public Long id;
|
||||
public Long account; // Outbox = null
|
||||
public Long parent;
|
||||
public Long uidv; // UIDValidity
|
||||
@NonNull
|
||||
public String name;
|
||||
@NonNull
|
||||
|
@ -287,6 +288,7 @@ public class EntityFolder extends EntityOrder implements Serializable {
|
|||
EntityFolder other = (EntityFolder) obj;
|
||||
return (this.id.equals(other.id) &&
|
||||
Objects.equals(this.account, other.account) &&
|
||||
Objects.equals(this.uidv, other.uidv) &&
|
||||
this.name.equals(other.name) &&
|
||||
this.type.equals(other.type) &&
|
||||
this.synchronize.equals(other.synchronize) &&
|
||||
|
|
Loading…
Reference in New Issue