Skip to content

Instantly share code, notes, and snippets.

@Atternatt
Last active July 9, 2019 18:47
Show Gist options
  • Save Atternatt/3cc6fb9b2a003a115d41c856b4cec726 to your computer and use it in GitHub Desktop.
Save Atternatt/3cc6fb9b2a003a115d41c856b4cec726 to your computer and use it in GitHub Desktop.
Rsync colector exporter class made in kotlin
class CollectorExporter constructor(context: Context,
private val executor: AppExecutor,
private val sync: Sync = SyncClient(context)) {
fun export(analyticsFolder: File, metadataFolder: File, collectorNetworkAddress: String, executor: ListeningExecutorService = this.executor, uploadFolder: String):
ListenableFuture<Unit> {
return executor.submit(Callable {
sync.sync(analyticsFolder.absolutePath, collectorNetworkAddress, uploadFolder)
sync.sync(metadataFolder.absolutePath, collectorNetworkAddress, uploadFolder)
})
}
fun export(file: File, collectorNetworkAddress: String, executor: ListeningExecutorService = this.executor, uploadFolder: String): ListenableFuture<Unit> {
return executor.submit(Callable {
sync.sync(file.absolutePath, collectorNetworkAddress, uploadFolder)
})
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment