57 lines
1.6 KiB
Java
57 lines
1.6 KiB
Java
package com.baidu.cloud.videocache.file;
|
|
|
|
import java.io.File;
|
|
import java.util.Iterator;
|
|
import java.util.List;
|
|
import java.util.concurrent.ExecutorService;
|
|
import java.util.concurrent.Executors;
|
|
import org.slf4j.Logger;
|
|
import org.slf4j.LoggerFactory;
|
|
|
|
/* loaded from: classes.dex */
|
|
public abstract class e implements DiskUsage {
|
|
private static final Logger b = LoggerFactory.getLogger("LruDiskUsage");
|
|
private final ExecutorService a = Executors.newSingleThreadExecutor();
|
|
|
|
private void a(List list) {
|
|
long b2 = b(list);
|
|
int size = list.size();
|
|
Iterator it = list.iterator();
|
|
while (it.hasNext()) {
|
|
File file = (File) it.next();
|
|
if (!a(file, b2, size)) {
|
|
long length = file.length();
|
|
if (file.delete()) {
|
|
size--;
|
|
b2 -= length;
|
|
b.info("Cache file " + file + " is deleted because it exceeds cache limit");
|
|
} else {
|
|
b.error("Error deleting file " + file + " for trimming cache");
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
private long b(List list) {
|
|
Iterator it = list.iterator();
|
|
long j = 0;
|
|
while (it.hasNext()) {
|
|
j += ((File) it.next()).length();
|
|
}
|
|
return j;
|
|
}
|
|
|
|
/* JADX INFO: Access modifiers changed from: private */
|
|
public void b(File file) {
|
|
b.c(file);
|
|
a(b.b(file.getParentFile()));
|
|
}
|
|
|
|
@Override // com.baidu.cloud.videocache.file.DiskUsage
|
|
public void a(File file) {
|
|
this.a.submit(new f(this, file));
|
|
}
|
|
|
|
protected abstract boolean a(File file, long j, int i);
|
|
}
|