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());