mirror of
https://github.com/recloudstream/cloudstream.git
synced 2024-08-15 01:53:11 +00:00
feat: add remote sync capability - run upload on activity destroy
This commit is contained in:
parent
78b0cad098
commit
842ac5fbe0
3 changed files with 8 additions and 2 deletions
|
@ -55,6 +55,7 @@ import com.lagradost.cloudstream3.plugins.PluginManager
|
|||
import com.lagradost.cloudstream3.plugins.PluginManager.loadAllOnlinePlugins
|
||||
import com.lagradost.cloudstream3.plugins.PluginManager.loadSinglePlugin
|
||||
import com.lagradost.cloudstream3.receivers.VideoDownloadRestartReceiver
|
||||
import com.lagradost.cloudstream3.syncproviders.AccountManager.Companion.BackupApis
|
||||
import com.lagradost.cloudstream3.syncproviders.AccountManager.Companion.OAuth2Apis
|
||||
import com.lagradost.cloudstream3.syncproviders.AccountManager.Companion.accountManagers
|
||||
import com.lagradost.cloudstream3.syncproviders.AccountManager.Companion.appString
|
||||
|
@ -612,6 +613,8 @@ class MainActivity : AppCompatActivity(), ColorPickerDialogListener {
|
|||
broadcastIntent.setClass(this, VideoDownloadRestartReceiver::class.java)
|
||||
this.sendBroadcast(broadcastIntent)
|
||||
afterPluginsLoadedEvent -= ::onAllPluginsLoaded
|
||||
// run sync before app quits
|
||||
BackupApis.forEach { it.addToQueueNow() }
|
||||
super.onDestroy()
|
||||
}
|
||||
|
||||
|
|
|
@ -102,12 +102,14 @@ interface BackupAPI<LOGIN_DATA> {
|
|||
return
|
||||
}
|
||||
|
||||
addToQueueNow()
|
||||
}
|
||||
fun addToQueueNow() {
|
||||
if (uploadJob != null && uploadJob!!.isActive) {
|
||||
Log.d(LOG_KEY, "upload is canceled, scheduling new")
|
||||
uploadJob?.cancel()
|
||||
}
|
||||
|
||||
// we should ensure job will before app is closed
|
||||
uploadJob = ioScope.launchSafe {
|
||||
Log.d(LOG_KEY, "upload is running now")
|
||||
uploadSyncData()
|
||||
|
|
|
@ -39,7 +39,7 @@ import java.util.Date
|
|||
*
|
||||
* | State | Priority | Description
|
||||
* |---------:|:--------:|---------------------------------------------------------------------
|
||||
* | Progress | 4 | Implement backup before user quits application
|
||||
* | Progress | 1 | Do not write sync meta when user is not syncing data
|
||||
* | Waiting | 2 | Add button to manually trigger sync
|
||||
* | Waiting | 3 | Move "https://chiff.github.io/cloudstream-sync/google-drive"
|
||||
* | Waiting | 5 | Choose what should be synced and recheck `invalidKeys` in createBackupScheduler
|
||||
|
@ -49,6 +49,7 @@ import java.util.Date
|
|||
* | Solved | 2 | Restoring backup should update view models
|
||||
* | Solved | 1 | Check if data was really changed when calling backupscheduler.work then
|
||||
* | | | dont update sync meta if not needed
|
||||
* | Solved | 4 | Implement backup before user quits application
|
||||
*/
|
||||
class GoogleDriveApi(index: Int) :
|
||||
InAppOAuth2APIManager(index),
|
||||
|
|
Loading…
Reference in a new issue