CcmNG: Some fixes
git-svn-id: https://svn.libreccm.org/ccm/ccm_ng@5695 8810af33-2d31-482b-a856-94f89814c4df
Former-commit-id: aa8b20c4b1
pull/2/head
parent
019d07940a
commit
65a9570a8d
|
|
@ -228,7 +228,12 @@ public class FileSystemThemeProvider implements ThemeProvider {
|
|||
final String path) {
|
||||
|
||||
final String themePath = createThemePath(theme, version);
|
||||
final String filePath = String.join("/", themePath, path);
|
||||
final String filePath;
|
||||
if ("/".equals(path)) {
|
||||
filePath = String.join("", themePath, path);
|
||||
} else {
|
||||
filePath = String.join("/", themePath, path);
|
||||
}
|
||||
|
||||
try {
|
||||
if (ccmFiles.isDirectory(filePath)) {
|
||||
|
|
@ -236,11 +241,13 @@ public class FileSystemThemeProvider implements ThemeProvider {
|
|||
.listFiles(filePath)
|
||||
.stream()
|
||||
.map(currentPath -> buildThemeFileInfo(
|
||||
String.join("/", theme, currentPath)))
|
||||
themePath,
|
||||
String.join("/", path, currentPath)))
|
||||
.collect(Collectors.toList());
|
||||
} else {
|
||||
final List<ThemeFileInfo> result = new ArrayList<>();
|
||||
final ThemeFileInfo fileInfo = buildThemeFileInfo(filePath);
|
||||
final ThemeFileInfo fileInfo = buildThemeFileInfo(
|
||||
themePath, path);
|
||||
result.add(fileInfo);
|
||||
|
||||
return result;
|
||||
|
|
@ -264,7 +271,7 @@ public class FileSystemThemeProvider implements ThemeProvider {
|
|||
try {
|
||||
if (ccmFiles.existsFile(filePath)) {
|
||||
|
||||
return Optional.of(buildThemeFileInfo(filePath));
|
||||
return Optional.of(buildThemeFileInfo(themePath, path));
|
||||
|
||||
} else {
|
||||
return Optional.empty();
|
||||
|
|
@ -445,14 +452,30 @@ public class FileSystemThemeProvider implements ThemeProvider {
|
|||
return Optional.of(themeInfo);
|
||||
}
|
||||
|
||||
private ThemeFileInfo buildThemeFileInfo(final String filePath) {
|
||||
private ThemeFileInfo buildThemeFileInfo(final String themePath,
|
||||
final String filePath) {
|
||||
|
||||
final String path;
|
||||
if (themePath.endsWith("/")
|
||||
|| filePath.startsWith("/")) {
|
||||
path = String.join("", themePath, filePath);
|
||||
} else {
|
||||
path= String.join("/", themePath, filePath);
|
||||
}
|
||||
|
||||
final String name;
|
||||
if (path.startsWith(("/"))) {
|
||||
name = path;
|
||||
} else {
|
||||
name = String.format("/%s", path);
|
||||
}
|
||||
|
||||
final ThemeFileInfo fileInfo = new ThemeFileInfo();
|
||||
|
||||
try {
|
||||
fileInfo.setDirectory(ccmFiles.isDirectory(filePath));
|
||||
fileInfo.setMimeType(ccmFiles.getMimeType(filePath));
|
||||
fileInfo.setName(filePath);
|
||||
fileInfo.setDirectory(ccmFiles.isDirectory(path));
|
||||
fileInfo.setMimeType(ccmFiles.getMimeType(path));
|
||||
fileInfo.setName(name);
|
||||
fileInfo.setWritable(true);
|
||||
|
||||
return fileInfo;
|
||||
|
|
|
|||
Loading…
Reference in New Issue