From 4b91b65d439c3064d0467007300266f52cdca557 Mon Sep 17 00:00:00 2001 From: Yutousama <583819556@qq.com> Date: Sun, 4 Jul 2021 01:43:40 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BF=AE=E5=A4=8D=E9=9F=B3=E4=B9=90=E6=97=A0?= =?UTF-8?q?=E6=B3=95=E8=AE=BF=E9=97=AE=E6=96=87=E4=BB=B6=E5=A4=B9=E5=86=85?= =?UTF-8?q?=E7=9A=84=E6=96=87=E4=BB=B6=20=E6=9B=B4=E6=96=B0QQbot=E7=89=88?= =?UTF-8?q?=E6=9C=AC?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- pom.xml | 2 +- .../com/yutou/nas/Controllers/MusicController.java | 4 ++-- .../nas/Services/impl/MusicToolsServiceImpl.java | 12 +++++++----- 3 files changed, 10 insertions(+), 8 deletions(-) diff --git a/pom.xml b/pom.xml index 4cf1c55..7fb2907 100644 --- a/pom.xml +++ b/pom.xml @@ -96,7 +96,7 @@ net.mamoe mirai-core-jvm - 2.5.0 + 2.6.7 org.jetbrains.kotlin diff --git a/src/main/java/com/yutou/nas/Controllers/MusicController.java b/src/main/java/com/yutou/nas/Controllers/MusicController.java index 8391660..22e2ae2 100644 --- a/src/main/java/com/yutou/nas/Controllers/MusicController.java +++ b/src/main/java/com/yutou/nas/Controllers/MusicController.java @@ -46,13 +46,13 @@ public class MusicController { public String getMusicListOfPath(@RequestBody JSONObject body) { String path = body.getString("path"); boolean type = body.containsKey("type") ? body.getBoolean("type") : false; - com.yutou.nas.utils.Log.i("接收到地址:" + path); if (StringUtils.isEmpty(path) - || path.equals("root") + || "root".equals(path) || !path.contains(defaultMusicPath) ) { path = defaultMusicPath; } + com.yutou.nas.utils.Log.i("接收到地址:" + path); //path=path.replace(defaultMusicPath+File.separator,""); JSONObject json = new JSONObject(); 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 40767c0..2ebe3b6 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"); @@ -112,9 +112,9 @@ public class MusicToolsServiceImpl implements IMusicToolsService { List list = new ArrayList<>(); List main = new ArrayList<>(); MusicDataExample example = new MusicDataExample(); - String replacement = ConfigTools.load(ConfigTools.CONFIG, "os").equals("windows") ? "\\\\" : "/"; + String replacement = "windows".equals(ConfigTools.load(ConfigTools.CONFIG, "os")) ? "\\\\" : "/"; String tmpPath = path; - if (isDir) { + if (new File(path).isDirectory()) { example.createCriteria().andFileLike(tmpPath.replace(File.separator, replacement) + "%"); main = musicDataDao.selectByExample(example); } @@ -125,9 +125,10 @@ public class MusicToolsServiceImpl implements IMusicToolsService { .replace("]", "\\]"); main.addAll(musicDataDao.selectByRegexp(tmpPath + replacement + "([^" + replacement + "]+)$")); - if (!path.equals(AppData.defaultMusicPath) && !path.equals("root")) { + if (!path.equals(AppData.defaultMusicPath) && !"root".equals(path)) { MusicData t2 = new MusicData(); t2.setTitle("返回"); + t2.setTrack("-1"); if (main.isEmpty()) { t2.setFile("root"); } else { @@ -186,6 +187,7 @@ public class MusicToolsServiceImpl implements IMusicToolsService { if (data != null) { try { if(getMusicData(file.getAbsolutePath())==null) { + // System.out.println(data); musicDataDao.insert(data); } } catch (Exception e) { @@ -270,7 +272,7 @@ public class MusicToolsServiceImpl implements IMusicToolsService { } data.setFile(file.getAbsolutePath()); data.setIsdir(file.isDirectory() ? 1 : 0); - data.setLastdir(file.getParentFile().getParent()); + data.setLastdir(file.getParentFile().getParent());//这里是设置上一级目录 AudioHeader header = audioFile.getAudioHeader(); data.setBitrate(header.getBitRate());