修复潜在的获取缓存大小报错问题

This commit is contained in:
lyswhut 2021-09-08 08:48:13 +08:00
parent 8b9c7988ee
commit e5ce1ade99
2 changed files with 16 additions and 29 deletions

View File

@ -13,14 +13,10 @@ public class Utils {
* @return
*/
static public long getDirSize(File dir) {
if (dir == null) {
return 0;
}
if (!dir.isDirectory()) {
return 0;
}
if (dir == null || !dir.isDirectory()) return 0;
long dirSize = 0;
File[] files = dir.listFiles();
if (files == null) return dirSize;
for (File file : files) {
if (file.isFile()) {
dirSize += file.length();
@ -59,21 +55,22 @@ public class Utils {
*/
static public int clearCacheFolder(File dir, long curTime) {
int deletedFiles = 0;
if (dir != null && dir.isDirectory()) {
try {
for (File child : dir.listFiles()) {
if (child.isDirectory()) {
deletedFiles += clearCacheFolder(child, curTime);
}
if (child.lastModified() < curTime) {
if (child.delete()) {
deletedFiles++;
}
if (dir == null || !dir.isDirectory()) return deletedFiles;
File[] files = dir.listFiles();
if (files == null) return deletedFiles;
try {
for (File child : files) {
if (child.isDirectory()) {
deletedFiles += clearCacheFolder(child, curTime);
}
if (child.lastModified() < curTime) {
if (child.delete()) {
deletedFiles++;
}
}
} catch (Exception e) {
e.printStackTrace();
}
} catch (Exception e) {
e.printStackTrace();
}
return deletedFiles;
}

View File

@ -1,13 +1,3 @@
### 新增
- 添加对通知栏歌曲进度条的支持
### 修复
- 修复某些情况下桌面歌词会导致APP崩溃的问题
- 修复从电脑浏览器复制的企鹅歌单链接无法打开的问题
### 其他
- 升级React native到v0.65.1
- 升级播放模块`react-native-track-player`到v2版本优化通知栏歌曲信息显示逻辑
- 修复潜在的获取缓存大小报错问题