修复音乐无法访问文件夹内的文件

更新QQbot版本
This commit is contained in:
Yutousama 2021-07-04 01:43:40 +08:00
parent 326bcfbf9e
commit 4b91b65d43
3 changed files with 10 additions and 8 deletions

View File

@ -96,7 +96,7 @@
<dependency>
<groupId>net.mamoe</groupId>
<artifactId>mirai-core-jvm</artifactId>
<version>2.5.0</version> <!-- 替换版本为你需要的版本 -->
<version>2.6.7</version> <!-- 替换版本为你需要的版本 -->
</dependency>
<dependency>
<groupId>org.jetbrains.kotlin</groupId>

View File

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

View File

@ -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<MusicData> list = new ArrayList<>();
List<MusicData> 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());