mirror of
https://github.com/bitfireAT/davx5-ose
synced 2024-10-07 03:42:59 +00:00
Log last sync time per collection service and URL (#702)
* Log last sync time per collection service and URL * Remove unused deprecated method * Include tasks and other services as caldav type
This commit is contained in:
parent
a246046f41
commit
b4e58eeb44
|
@ -50,10 +50,6 @@ interface CollectionDao {
|
|||
@Query("SELECT collection.* FROM collection, homeset WHERE collection.serviceId=:serviceId AND type=:type AND homeSetId=homeset.id AND homeset.personal ORDER BY collection.displayName COLLATE NOCASE, collection.url COLLATE NOCASE")
|
||||
fun pagePersonalByServiceAndType(serviceId: Long, type: String): PagingSource<Int, Collection>
|
||||
|
||||
@Deprecated("Use getByServiceAndUrl instead")
|
||||
@Query("SELECT * FROM collection WHERE url=:url")
|
||||
fun getByUrl(url: String): Collection?
|
||||
|
||||
@Query("SELECT * FROM collection WHERE serviceId=:serviceId AND url=:url")
|
||||
fun getByServiceAndUrl(serviceId: Long, url: String): Collection?
|
||||
|
||||
|
|
|
@ -38,6 +38,7 @@ import at.bitfire.dav4jvm.property.webdav.SyncToken
|
|||
import at.bitfire.davdroid.InvalidAccountException
|
||||
import at.bitfire.davdroid.R
|
||||
import at.bitfire.davdroid.db.AppDatabase
|
||||
import at.bitfire.davdroid.db.Service
|
||||
import at.bitfire.davdroid.db.SyncState
|
||||
import at.bitfire.davdroid.db.SyncStats
|
||||
import at.bitfire.davdroid.log.Logger
|
||||
|
@ -185,14 +186,7 @@ abstract class SyncManager<ResourceType: LocalResource<*>, out CollectionType: L
|
|||
}
|
||||
|
||||
// log sync time
|
||||
val db = EntryPointAccessors.fromApplication(context, SyncManagerEntryPoint::class.java).appDatabase()
|
||||
db.runInTransaction {
|
||||
db.collectionDao().getByUrl(collectionURL.toString())?.let { collection ->
|
||||
db.syncStatsDao().insertOrReplace(
|
||||
SyncStats(0, collection.id, authority, System.currentTimeMillis())
|
||||
)
|
||||
}
|
||||
}
|
||||
logSyncTime()
|
||||
|
||||
Logger.log.info("Querying server capabilities")
|
||||
var remoteSyncState = queryCapabilities()
|
||||
|
@ -332,6 +326,26 @@ abstract class SyncManager<ResourceType: LocalResource<*>, out CollectionType: L
|
|||
})
|
||||
}
|
||||
|
||||
private fun logSyncTime() {
|
||||
val serviceType = when (authority) {
|
||||
ContactsContract.AUTHORITY, // Contacts
|
||||
context.getString(R.string.address_books_authority) -> // Address books
|
||||
Service.TYPE_CARDDAV
|
||||
else -> // Calendars + other (ie. tasks)
|
||||
Service.TYPE_CALDAV
|
||||
}
|
||||
val db = EntryPointAccessors.fromApplication(context, SyncManagerEntryPoint::class.java).appDatabase()
|
||||
db.runInTransaction {
|
||||
val service = db.serviceDao().getByAccountAndType(account.name, serviceType)
|
||||
?: return@runInTransaction
|
||||
val collection = db.collectionDao().getByServiceAndUrl(service.id, collectionURL.toString())
|
||||
?: return@runInTransaction
|
||||
db.syncStatsDao().insertOrReplace(
|
||||
SyncStats(0, collection.id, authority, System.currentTimeMillis())
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Prepares synchronization. Sets the lateinit properties [collectionURL] and [davCollection].
|
||||
|
|
Loading…
Reference in a new issue