|
|
@@ -139,6 +139,7 @@ public class ResourceServiceImpl implements ResourceService {
|
|
|
if (dir == null || !dir.exists()) {
|
|
|
return resources;
|
|
|
}
|
|
|
+ resources.add(convertToResource(dir));
|
|
|
if (dir.isDirectory()) {
|
|
|
// 递归获取所有资源
|
|
|
File[] files = dir.listFiles();
|
|
|
@@ -146,7 +147,6 @@ public class ResourceServiceImpl implements ResourceService {
|
|
|
resources.addAll(getLocalResources(file));
|
|
|
}
|
|
|
}
|
|
|
- resources.add(convertToResource(dir));
|
|
|
return resources;
|
|
|
}
|
|
|
|
|
|
@@ -199,7 +199,11 @@ public class ResourceServiceImpl implements ResourceService {
|
|
|
private void downloadFile(Resource resource) throws ClientProtocolException, URISyntaxException, IOException {
|
|
|
// 如果资源是文件夹,在本地创建
|
|
|
if (resource.isFolder()) {
|
|
|
- new File(jsRestAPIConf.getLocalBaseDir() + resource.getUri()).mkdirs();
|
|
|
+ File folder = new File(jsRestAPIConf.getLocalBaseDir() + resource.getUri());
|
|
|
+ if (!folder.exists()) {
|
|
|
+ folder.mkdirs();
|
|
|
+ logger.info("Mkdirs " + folder.getPath());
|
|
|
+ }
|
|
|
return;
|
|
|
}
|
|
|
|
|
|
@@ -242,9 +246,11 @@ public class ResourceServiceImpl implements ResourceService {
|
|
|
// 该文件所在的路径不存在,创建
|
|
|
if (!exportFile.getParentFile().exists()) {
|
|
|
exportFile.getParentFile().mkdirs();
|
|
|
+ logger.info("Mkdirs " + exportFile.getParent());
|
|
|
}
|
|
|
FileOutputStream fos = new FileOutputStream(exportFile);
|
|
|
fos.write(data);
|
|
|
+ fos.flush();
|
|
|
fos.close();
|
|
|
logger.info("Download resource to " + exportPath + "\n");
|
|
|
}
|