Skip to content

Commit

Permalink
fix: 某些情况下磁盘缓存无法删除的问题
Browse files Browse the repository at this point in the history
  • Loading branch information
wyouflf committed Feb 26, 2017
1 parent 8f223b2 commit d28075a
Showing 1 changed file with 20 additions and 12 deletions.
32 changes: 20 additions & 12 deletions xutils/src/main/java/org/xutils/cache/LruDiskCache.java
Original file line number Diff line number Diff line change
Expand Up @@ -269,13 +269,17 @@ public void run() {
if (rmList != null && rmList.size() > 0) {
// delete cache files
for (DiskCacheEntity entity : rmList) {
String path = entity.getPath();
if (!TextUtils.isEmpty(path)) {
if (deleteFileWithLock(path)
&& deleteFileWithLock(path + TEMP_FILE_SUFFIX)) {
// delete db entity
cacheDb.delete(entity);
try {
// delete db entity
cacheDb.delete(entity);
// delete cache files
String path = entity.getPath();
if (!TextUtils.isEmpty(path)) {
deleteFileWithLock(path);
deleteFileWithLock(path + TEMP_FILE_SUFFIX);
}
} catch (DbException ex) {
LogUtil.e(ex.getMessage(), ex);
}
}

Expand All @@ -293,13 +297,17 @@ && deleteFileWithLock(path + TEMP_FILE_SUFFIX)) {
if (rmList != null && rmList.size() > 0) {
// delete cache files
for (DiskCacheEntity entity : rmList) {
String path = entity.getPath();
if (!TextUtils.isEmpty(path)) {
if (deleteFileWithLock(path)
&& deleteFileWithLock(path + TEMP_FILE_SUFFIX)) {
// delete db entity
cacheDb.delete(entity);
try {
// delete db entity
cacheDb.delete(entity);
// delete cache files
String path = entity.getPath();
if (!TextUtils.isEmpty(path)) {
deleteFileWithLock(path);
deleteFileWithLock(path + TEMP_FILE_SUFFIX);
}
} catch (DbException ex) {
LogUtil.e(ex.getMessage(), ex);
}
}
}
Expand Down

0 comments on commit d28075a

Please sign in to comment.