修复音乐返回异常问题

This commit is contained in:
Yutousama 2021-07-04 12:15:13 +08:00
parent 4b91b65d43
commit 4ffd94e3d1

View File

@ -56,7 +56,7 @@ public class MusicToolsServiceImpl implements IMusicToolsService {
if (isScan) { if (isScan) {
return; return;
} }
if (!ConfigTools.load(ConfigTools.CONFIG, "musicScan",boolean.class,false)) { if (!ConfigTools.load(ConfigTools.CONFIG, "musicScan", boolean.class, false)) {
return; return;
} }
musicPath = (String) ConfigTools.load(ConfigTools.CONFIG, "musicDir"); musicPath = (String) ConfigTools.load(ConfigTools.CONFIG, "musicDir");
@ -132,8 +132,7 @@ public class MusicToolsServiceImpl implements IMusicToolsService {
if (main.isEmpty()) { if (main.isEmpty()) {
t2.setFile("root"); t2.setFile("root");
} else { } else {
MusicData tmp = main.get(0); t2.setFile(new File(path).getParent());
t2.setFile(new File(tmp.getLastdir()).getAbsolutePath());
} }
com.yutou.nas.utils.Log.i("查询地址:" + path + " 设置返回地址:" + t2.getFile()); com.yutou.nas.utils.Log.i("查询地址:" + path + " 设置返回地址:" + t2.getFile());
t2.setIsdir(1); t2.setIsdir(1);
@ -162,8 +161,8 @@ public class MusicToolsServiceImpl implements IMusicToolsService {
private void getDirList(String path, List<MusicData> list) { private void getDirList(String path, List<MusicData> list) {
File file = new File(path); File file = new File(path);
com.yutou.nas.utils.Log.i("扫描文件:"+path); com.yutou.nas.utils.Log.i("扫描文件:" + path);
if(file.isDirectory()) { if (file.isDirectory()) {
for (File listFile : file.listFiles()) { for (File listFile : file.listFiles()) {
if (listFile.isDirectory()) { if (listFile.isDirectory()) {
MusicData data = new MusicData(); MusicData data = new MusicData();
@ -173,7 +172,7 @@ public class MusicToolsServiceImpl implements IMusicToolsService {
list.add(data); list.add(data);
} }
} }
}else{ } else {
MusicData data = new MusicData(); MusicData data = new MusicData();
data.setTitle(file.getName()); data.setTitle(file.getName());
data.setIsdir(0); data.setIsdir(0);
@ -186,8 +185,8 @@ public class MusicToolsServiceImpl implements IMusicToolsService {
MusicData data = getMetadata(file); MusicData data = getMetadata(file);
if (data != null) { if (data != null) {
try { try {
if(getMusicData(file.getAbsolutePath())==null) { if (getMusicData(file.getAbsolutePath()) == null) {
// System.out.println(data); // System.out.println(data);
musicDataDao.insert(data); musicDataDao.insert(data);
} }
} catch (Exception e) { } catch (Exception e) {