VictorAlbertos / ReactiveCache

A reactive cache for Android and Java which honors the reactive chain.
Apache License 2.0
240 stars 24 forks source link

Issues with encrypt #19

Closed NaSOS closed 4 years ago

NaSOS commented 6 years ago

Hello, I am trying to enable encryption but when I do the cache is not working and constantly loads data from the network.

What am I doing:

@Provides @Singleton fun provideCache(@ApplicationContext context: Context): ReactiveCache =
            ReactiveCache.Builder()
                    .encrypt("test")
                    .useExpiredDataWhenNoLoaderAvailable()
                    .using(context.filesDir, MoshiSpeaker())

And for the provider:

private val cacheProvider: ProviderList<Ingredient> = reactiveCache.providerList<Ingredient>()
            .encrypt(true)
            .lifeCache(1, TimeUnit.DAYS)
            .withKey("ingredients")

I tried to debug a bit in case I was doing something wrong and I noticed that during Disk.retrieveRecord() the File passed to jolyglot was not properly decrypted and as a result the json parsing was failing with:

java.lang.RuntimeException: com.squareup.moshi.JsonEncodingException: Use JsonReader.setLenient(true) to accept malformed JSON at path $

I am attaching a screenshot of the MoshiSpeaker.fromJson where it shows that the BufferedSource passed to JsonReader is not valid.

screen shot 2017-11-19 at 13 57 21

Can you please help? Thanks a lot!!

VictorAlbertos commented 6 years ago

Please @miguelbcr can you take a look this?

The0ldM0nk commented 6 years ago

I concur with @NaSOS 🛠

The0ldM0nk commented 6 years ago

@VictorAlbertos @miguelbcr any update on this guys? Thanks!

VictorAlbertos commented 4 years ago

Sorry we have no time to actively maintain this library anymore, but feel free to collaborate fixing this issue by opening a PR 👍