package com.helpshift.cache; import com.helpshift.storage.HSPersistentStorage; import java.io.File; /* loaded from: classes3.dex */ public class HelpcenterCacheEvictionManager { public final String appFileDirPath; public final HSPersistentStorage persistentStorage; public String subdirPath; public HelpcenterCacheEvictionManager(HSPersistentStorage hSPersistentStorage, String str, String str2) { this.persistentStorage = hSPersistentStorage; this.appFileDirPath = str; this.subdirPath = str2; } public void deleteOlderHelpcenterCachedFiles() { long currentTimeMillis = System.currentTimeMillis(); long lastHCCacheEvictedTime = this.persistentStorage.getLastHCCacheEvictedTime(); if (lastHCCacheEvictedTime == 0) { updateLastCacheEvictedTime(currentTimeMillis); return; } if (currentTimeMillis - lastHCCacheEvictedTime < 604800000) { return; } updateLastCacheEvictedTime(currentTimeMillis); File[] listFiles = new File(getResourceCacheDirPath()).listFiles(); if (listFiles == null || listFiles.length == 0) { return; } for (File file : listFiles) { long lastModified = file.lastModified(); if (lastModified != 0 && currentTimeMillis - lastModified > 2592000000L) { file.delete(); } } } public final void updateLastCacheEvictedTime(long j) { this.persistentStorage.setLastHCCacheEvictedTime(j); } public final String getResourceCacheDirPath() { StringBuilder sb = new StringBuilder(); sb.append(this.appFileDirPath); String str = File.separator; sb.append(str); sb.append("helpshift"); sb.append(str); sb.append("resource_cache"); sb.append(str); sb.append(this.subdirPath); return sb.toString(); } }