mirror of
https://github.com/tencentmusic/supersonic.git
synced 2025-12-14 05:43:51 +00:00
[improvement][headless] Handle compatibility issues when loading all files under the window directory (#1776)
This commit is contained in:
@@ -6,6 +6,8 @@ import lombok.extern.slf4j.Slf4j;
|
|||||||
|
|
||||||
import java.io.File;
|
import java.io.File;
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
|
import java.nio.file.Path;
|
||||||
|
import java.nio.file.Paths;
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
@@ -45,7 +47,8 @@ public class FileHelper {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private static String getCustomPath(String[] path) {
|
private static String getCustomPath(String[] path) {
|
||||||
return path[0].substring(0, path[0].lastIndexOf(FILE_SPILT)) + FILE_SPILT;
|
Path firstPath = Paths.get(path[0]).normalize();
|
||||||
|
return firstPath.getParent().toString() + File.separator;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|||||||
@@ -11,6 +11,7 @@ import org.apache.hadoop.fs.Path;
|
|||||||
|
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
import java.net.URI;
|
import java.net.URI;
|
||||||
|
import java.nio.file.Paths;
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
@@ -59,11 +60,14 @@ public class HdfsFileHelper {
|
|||||||
String[] path = Config.CustomDictionaryPath;
|
String[] path = Config.CustomDictionaryPath;
|
||||||
FileSystem fs = FileSystem.get(URI.create(path[0]), new Configuration());
|
FileSystem fs = FileSystem.get(URI.create(path[0]), new Configuration());
|
||||||
String cacheFilePath = path[0] + Predefine.BIN_EXT;
|
String cacheFilePath = path[0] + Predefine.BIN_EXT;
|
||||||
int customBase = cacheFilePath.lastIndexOf(FileHelper.FILE_SPILT);
|
|
||||||
String customPath =
|
java.nio.file.Path normalizedPath = Paths.get(cacheFilePath).normalize();
|
||||||
cacheFilePath.substring(0, customBase) + FileHelper.FILE_SPILT + "*.txt";
|
int customBase = normalizedPath.toString().lastIndexOf(FileHelper.FILE_SPILT);
|
||||||
log.info("customPath:{}", customPath);
|
String customPathStr = normalizedPath.toString().substring(0, customBase)
|
||||||
List<String> fileList = getFileList(fs, new Path(customPath));
|
+ FileHelper.FILE_SPILT + "*.txt";
|
||||||
|
|
||||||
|
log.info("customPath:{}", customPathStr);
|
||||||
|
List<String> fileList = getFileList(fs, new Path(customPathStr));
|
||||||
log.info("CustomDictionaryPath:{}", fileList);
|
log.info("CustomDictionaryPath:{}", fileList);
|
||||||
Config.CustomDictionaryPath = fileList.toArray(new String[0]);
|
Config.CustomDictionaryPath = fileList.toArray(new String[0]);
|
||||||
customDictionary.path =
|
customDictionary.path =
|
||||||
|
|||||||
Reference in New Issue
Block a user