fix: remove cache for OkHttpClient
This commit is contained in:
parent
20939f9ba0
commit
d3bb9d30aa
@ -7,11 +7,8 @@ import com.pcloud.sdk.Authenticators;
|
||||
import com.pcloud.sdk.PCloudSdk;
|
||||
|
||||
import org.cryptomator.data.cloud.okhttplogging.HttpLoggingInterceptor;
|
||||
import org.cryptomator.util.SharedPreferencesHandler;
|
||||
import org.cryptomator.util.crypto.CredentialCryptor;
|
||||
import org.cryptomator.util.file.LruFileCacheUtil;
|
||||
|
||||
import okhttp3.Cache;
|
||||
import okhttp3.Interceptor;
|
||||
import okhttp3.OkHttpClient;
|
||||
import timber.log.Timber;
|
||||
@ -30,13 +27,12 @@ class PCloudClientFactory {
|
||||
|
||||
public ApiClient getClient(String accessToken, String url, Context context) {
|
||||
if (apiClient == null) {
|
||||
final SharedPreferencesHandler sharedPreferencesHandler = new SharedPreferencesHandler(context);
|
||||
apiClient = createApiClient(accessToken, url, context, sharedPreferencesHandler.useLruCache(), sharedPreferencesHandler.lruCacheSize());
|
||||
apiClient = createApiClient(accessToken, url, context);
|
||||
}
|
||||
return apiClient;
|
||||
}
|
||||
|
||||
private ApiClient createApiClient(String accessToken, String url, Context context, boolean useLruCache, int lruCacheSize) {
|
||||
private ApiClient createApiClient(String accessToken, String url, Context context) {
|
||||
OkHttpClient.Builder okHttpClientBuilder = new OkHttpClient() //
|
||||
.newBuilder() //
|
||||
.connectTimeout(CONNECTION.getTimeout(), CONNECTION.getUnit()) //
|
||||
@ -44,10 +40,6 @@ class PCloudClientFactory {
|
||||
.writeTimeout(WRITE.getTimeout(), WRITE.getUnit()) //
|
||||
.addInterceptor(httpLoggingInterceptor(context)); //;
|
||||
|
||||
if (useLruCache) {
|
||||
okHttpClientBuilder.cache(new Cache(new LruFileCacheUtil(context).resolve(LruFileCacheUtil.Cache.PCLOUD), lruCacheSize));
|
||||
}
|
||||
|
||||
OkHttpClient okHttpClient = okHttpClientBuilder.build();
|
||||
|
||||
return PCloudSdk.newClientBuilder().authenticator(Authenticators.newOAuthAuthenticator(decrypt(accessToken, context))).withClient(okHttpClient).apiHost(url).create();
|
||||
|
Loading…
x
Reference in New Issue
Block a user