From 4ffd94e3d149d906a5ec5449ba497fcdbb4b6579 Mon Sep 17 00:00:00 2001 From: Yutousama <583819556@qq.com> Date: Sun, 4 Jul 2021 12:15:13 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BF=AE=E5=A4=8D=E9=9F=B3=E4=B9=90=E8=BF=94?= =?UTF-8?q?=E5=9B=9E=E5=BC=82=E5=B8=B8=E9=97=AE=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../nas/Services/impl/MusicToolsServiceImpl.java | 15 +++++++-------- 1 file changed, 7 insertions(+), 8 deletions(-) diff --git a/src/main/java/com/yutou/nas/Services/impl/MusicToolsServiceImpl.java b/src/main/java/com/yutou/nas/Services/impl/MusicToolsServiceImpl.java index 2ebe3b6..644c0fa 100644 --- a/src/main/java/com/yutou/nas/Services/impl/MusicToolsServiceImpl.java +++ b/src/main/java/com/yutou/nas/Services/impl/MusicToolsServiceImpl.java @@ -56,7 +56,7 @@ public class MusicToolsServiceImpl implements IMusicToolsService { if (isScan) { return; } - if (!ConfigTools.load(ConfigTools.CONFIG, "musicScan",boolean.class,false)) { + if (!ConfigTools.load(ConfigTools.CONFIG, "musicScan", boolean.class, false)) { return; } musicPath = (String) ConfigTools.load(ConfigTools.CONFIG, "musicDir"); @@ -132,8 +132,7 @@ public class MusicToolsServiceImpl implements IMusicToolsService { if (main.isEmpty()) { t2.setFile("root"); } else { - MusicData tmp = main.get(0); - t2.setFile(new File(tmp.getLastdir()).getAbsolutePath()); + t2.setFile(new File(path).getParent()); } com.yutou.nas.utils.Log.i("查询地址:" + path + " 设置返回地址:" + t2.getFile()); t2.setIsdir(1); @@ -162,8 +161,8 @@ public class MusicToolsServiceImpl implements IMusicToolsService { private void getDirList(String path, List list) { File file = new File(path); - com.yutou.nas.utils.Log.i("扫描文件:"+path); - if(file.isDirectory()) { + com.yutou.nas.utils.Log.i("扫描文件:" + path); + if (file.isDirectory()) { for (File listFile : file.listFiles()) { if (listFile.isDirectory()) { MusicData data = new MusicData(); @@ -173,7 +172,7 @@ public class MusicToolsServiceImpl implements IMusicToolsService { list.add(data); } } - }else{ + } else { MusicData data = new MusicData(); data.setTitle(file.getName()); data.setIsdir(0); @@ -186,8 +185,8 @@ public class MusicToolsServiceImpl implements IMusicToolsService { MusicData data = getMetadata(file); if (data != null) { try { - if(getMusicData(file.getAbsolutePath())==null) { - // System.out.println(data); + if (getMusicData(file.getAbsolutePath()) == null) { + // System.out.println(data); musicDataDao.insert(data); } } catch (Exception e) {