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