update to v1.0.29-release 稳定性更新

This commit is contained in:
kohgylw@163.com 2020-05-12 10:19:51 +08:00
parent 7fe850feb4
commit 27f3a72caf
14 changed files with 89 additions and 79 deletions

View File

@ -72,5 +72,5 @@ _提示源代码路径下包含了一些程序运行所需的非源代码资
### 联系作者?
如有任何需要(例如对该资源有疑问、意见或建议),请发件联系作者: kohgylw@163.com (青阳龙野),随时恭候您的来信!
青阳龙野@kohgylw by 2020年05月06
青阳龙野@kohgylw by 2020年05月12

View File

@ -145,4 +145,5 @@ test.auth.xxx=ucd
【已完成】修复了上传文件夹功能无法上传Unix/Linux系统中的隐藏文件夹以“.”开头)的问题。
【已完成】修复了上传文件和上传文件夹功能在取消时会互相冲突的问题。
【已完成】修复了一些情况下快捷键会失效或功能异常的问题。
【已完成】(追加)修复了在“管理文件系统路径”窗口中修改文件系统存储路径时如果取消操作会导致所有按钮无法回弹的问题。
【已完成】其他一些细节优化。

View File

@ -91,7 +91,7 @@ public class ExternalDownloadServiceImpl extends RangeFileStreamWriter implement
if (target != null && target.isFile()) {
String range = request.getHeader("Range");
int status = writeRangeFileStream(request, response, target, f.getFileName(), CONTENT_TYPE,
ConfigureReader.instance().getDownloadMaxRate(null), fbu.getETag(target));
ConfigureReader.instance().getDownloadMaxRate(null), fbu.getETag(target), true);
if (status == HttpServletResponse.SC_OK || (range != null && range.startsWith("bytes=0-"))) {
this.lu.writeDownloadFileByKeyEvent(request, f);
}

View File

@ -68,7 +68,7 @@ public class FileChainServiceImpl extends RangeFileStreamWriter implements FileC
String range = request.getHeader("Range");
int status = writeRangeFileStream(request, response, target, f.getFileName(),
ctm.getContentType(suffix), ConfigureReader.instance().getDownloadMaxRate(null),
fbu.getETag(target));
fbu.getETag(target), false);
if (status == HttpServletResponse.SC_OK
|| (range != null && range.startsWith("bytes=0-"))) {
this.lu.writeChainEvent(request, f);

View File

@ -332,7 +332,7 @@ public class FileServiceImpl extends RangeFileStreamWriter implements FileServic
final String range = request.getHeader("Range");
if (fo != null) {
int status = writeRangeFileStream(request, response, fo, f.getFileName(), CONTENT_TYPE,
ConfigureReader.instance().getDownloadMaxRate(account), fbu.getETag(fo));
ConfigureReader.instance().getDownloadMaxRate(account), fbu.getETag(fo), true);
// 日志记录仅针对一次下载
if (status == HttpServletResponse.SC_OK
|| (range != null && range.startsWith("bytes=0-"))) {
@ -500,7 +500,7 @@ public class FileServiceImpl extends RangeFileStreamWriter implements FileServic
String fname = "kiftd_" + ServerTimeUtil.accurateToDay() + "_\u6253\u5305\u4e0b\u8f7d.zip";
if (zip.exists()) {
writeRangeFileStream(request, response, zip, fname, CONTENT_TYPE,
ConfigureReader.instance().getDownloadMaxRate(account), fbu.getETag(zip));
ConfigureReader.instance().getDownloadMaxRate(account), fbu.getETag(zip), true);
zip.delete();
}
}

View File

@ -44,10 +44,14 @@ public class RangeFileStreamWriter {
* java.lang.String HTTP Content-Type类型用于控制客户端行为
* @param maxRate
* long 最大输出速率以KB/s为单位若为负数则不限制输出速率用于限制客户端的下载速度
* @param eTag
* java.lang.String 资源的唯一性标识例如"aabbcc"
* @param isAttachment
* boolean 是否作为附件回传若希望用户下载则应设置为true
* @return int 操作结束时返回的状态码
*/
protected int writeRangeFileStream(HttpServletRequest request, HttpServletResponse response, File fo, String fname,
String contentType, long maxRate, String eTag) {
String contentType, long maxRate, String eTag, boolean isAttachment) {
long fileLength = fo.length();// 文件总大小
long startOffset = 0; // 起始偏移量
boolean hasEnd = false;// 请求区间是否存在结束标识
@ -95,14 +99,20 @@ public class RangeFileStreamWriter {
response.setContentType(contentType);
// 设置文件信息
response.setCharacterEncoding("UTF-8");
if (request.getHeader("User-Agent").toLowerCase().indexOf("safari") >= 0) {
response.setHeader("Content-Disposition",
"attachment; filename=\""
+ new String(fname.getBytes(Charset.forName("UTF-8")), Charset.forName("ISO-8859-1"))
+ "\"; filename*=utf-8''" + EncodeUtil.getFileNameByUTF8(fname));
// 设置Content-Disposition信息
if (isAttachment) {
if (request.getHeader("User-Agent").toLowerCase().indexOf("safari") >= 0) {
response.setHeader("Content-Disposition",
"attachment; filename=\""
+ new String(fname.getBytes(Charset.forName("UTF-8")), Charset.forName("ISO-8859-1"))
+ "\"; filename*=utf-8''" + EncodeUtil.getFileNameByUTF8(fname));
} else {
response.setHeader("Content-Disposition",
"attachment; filename=\"" + EncodeUtil.getFileNameByUTF8(fname) + "\"; filename*=utf-8''"
+ EncodeUtil.getFileNameByUTF8(fname));
}
} else {
response.setHeader("Content-Disposition", "attachment; filename=\"" + EncodeUtil.getFileNameByUTF8(fname)
+ "\"; filename*=utf-8''" + EncodeUtil.getFileNameByUTF8(fname));
response.setHeader("Content-Disposition", "inline");
}
// 设置支持断点续传功能
response.setHeader("Accept-Ranges", "bytes");

View File

@ -42,7 +42,7 @@ public class FileSystemPathViewer extends KiftdDynamicWindow {
private JButton changeBtn;// 修改按钮
private JButton removeBtn;// 删除按钮
private PathsTable pathsTable;// 文件列表对象
private int maxExtendStoresNum;//最大扩展存储区数目
private int maxExtendStoresNum;// 最大扩展存储区数目
private static FileSystemPathViewer fsv;// 该窗口的唯一实例
private static List<FileSystemPath> paths;// 当前显示的视图
@ -80,7 +80,7 @@ public class FileSystemPathViewer extends KiftdDynamicWindow {
toolBar.addSeparator();
c.add(toolBar, BorderLayout.NORTH);
// 各个工具栏按钮的功能实现
maxExtendStoresNum=SettingWindow.st==null?0:SettingWindow.st.getMaxExtendStoresNum();
maxExtendStoresNum = SettingWindow.st == null ? 0 : SettingWindow.st.getMaxExtendStoresNum();
addBtn.addActionListener((e) -> {
disableAllButtons();
if (SettingWindow.extendStores.size() < maxExtendStoresNum) {
@ -127,78 +127,77 @@ public class FileSystemPathViewer extends KiftdDynamicWindow {
changeBtn.addActionListener((e) -> {
disableAllButtons();
if (JOptionPane.showConfirmDialog(window, "确认要修改该存储路径么?警告:修改为新路径后,该存储区内原先存放的数据将会丢失。", "修改路径",
JOptionPane.YES_NO_OPTION) != JOptionPane.YES_OPTION) {
return;
}
short index = pathsTable.getSelectFileSystemIndex();
if (index == 0) {
JFileChooser mainFileSystemPathChooer = new JFileChooser();
mainFileSystemPathChooer.setFileSelectionMode(JFileChooser.DIRECTORIES_ONLY);
mainFileSystemPathChooer.setPreferredSize(fileChooerSize);
if (SettingWindow.st != null) {
File fileSystemPath = new File(SettingWindow.st.getFileSystemPath());
if (fileSystemPath.isDirectory()) {
mainFileSystemPathChooer.setCurrentDirectory(fileSystemPath);
}
}
mainFileSystemPathChooer.setDialogTitle("请选择主文件系统存储路径");
if (mainFileSystemPathChooer.showOpenDialog(null) == JFileChooser.APPROVE_OPTION) {
File selectPath = mainFileSystemPathChooer.getSelectedFile();
if (selectPath.isDirectory() && selectPath.canWrite() && selectPath.canRead()) {
if (!SettingWindow.extendStores.parallelStream()
.anyMatch(f -> f.getPath().equals(selectPath))) {
String pathName = selectPath.getAbsolutePath();
if (new File(ConfigureReader.instance().getInitFileSystemPath()).equals(selectPath)
|| (encoder.canEncode(pathName) && pathName.indexOf("\\:") < 0
&& pathName.indexOf("\\\\") < 0)) {
SettingWindow.chooserPath = mainFileSystemPathChooer.getSelectedFile();
} else {
JOptionPane.showMessageDialog(window, INVALID_PATH_ALTER, "错误",
JOptionPane.WARNING_MESSAGE);
}
} else {
JOptionPane.showMessageDialog(window, "错误:该路径已被某个扩展存储区占用。", "错误",
JOptionPane.WARNING_MESSAGE);
JOptionPane.YES_NO_OPTION) == JOptionPane.YES_OPTION) {
short index = pathsTable.getSelectFileSystemIndex();
if (index == 0) {
JFileChooser mainFileSystemPathChooer = new JFileChooser();
mainFileSystemPathChooer.setFileSelectionMode(JFileChooser.DIRECTORIES_ONLY);
mainFileSystemPathChooer.setPreferredSize(fileChooerSize);
if (SettingWindow.st != null) {
File fileSystemPath = new File(SettingWindow.st.getFileSystemPath());
if (fileSystemPath.isDirectory()) {
mainFileSystemPathChooer.setCurrentDirectory(fileSystemPath);
}
} else {
JOptionPane.showMessageDialog(window, "错误:该路径不可用,必须选择可读写的文件夹。", "错误",
JOptionPane.WARNING_MESSAGE);
}
}
} else {
JFileChooser mainFileSystemPathChooer = new JFileChooser();
mainFileSystemPathChooer.setFileSelectionMode(JFileChooser.DIRECTORIES_ONLY);
mainFileSystemPathChooer.setPreferredSize(fileChooerSize);
FileSystemPath fsp = null;
for (int i = 0; i < SettingWindow.extendStores.size(); i++) {
if (SettingWindow.extendStores.get(i).getIndex() == index) {
fsp = SettingWindow.extendStores.get(i);
mainFileSystemPathChooer.setCurrentDirectory(fsp.getPath());
mainFileSystemPathChooer.setDialogTitle("请选择扩展存储区路径");
if (mainFileSystemPathChooer.showOpenDialog(null) == JFileChooser.APPROVE_OPTION) {
disableAllButtons();
File selectPath = mainFileSystemPathChooer.getSelectedFile();
if (selectPath.isDirectory() && selectPath.canWrite() && selectPath.canRead()) {
if (fsp.getPath().equals(selectPath) || !SettingWindow.extendStores.parallelStream()
.anyMatch(f -> f.getPath().equals(selectPath))) {
String pathName = selectPath.getAbsolutePath();
if (encoder.canEncode(pathName) && pathName.indexOf("\\:") < 0
&& pathName.indexOf("\\\\") < 0) {
fsp.setPath(mainFileSystemPathChooer.getSelectedFile());
} else {
JOptionPane.showMessageDialog(window, INVALID_PATH_ALTER, "错误",
JOptionPane.WARNING_MESSAGE);
}
mainFileSystemPathChooer.setDialogTitle("请选择主文件系统存储路径");
if (mainFileSystemPathChooer.showOpenDialog(null) == JFileChooser.APPROVE_OPTION) {
File selectPath = mainFileSystemPathChooer.getSelectedFile();
if (selectPath.isDirectory() && selectPath.canWrite() && selectPath.canRead()) {
if (!SettingWindow.extendStores.parallelStream()
.anyMatch(f -> f.getPath().equals(selectPath))) {
String pathName = selectPath.getAbsolutePath();
if (new File(ConfigureReader.instance().getInitFileSystemPath()).equals(selectPath)
|| (encoder.canEncode(pathName) && pathName.indexOf("\\:") < 0
&& pathName.indexOf("\\\\") < 0)) {
SettingWindow.chooserPath = mainFileSystemPathChooer.getSelectedFile();
} else {
JOptionPane.showMessageDialog(window, "错误:该路径已被其他扩展存储区占用。", "错误",
JOptionPane.showMessageDialog(window, INVALID_PATH_ALTER, "错误",
JOptionPane.WARNING_MESSAGE);
}
} else {
JOptionPane.showMessageDialog(window, "错误:该路径不可用,必须选择可读写的文件夹", "错误",
JOptionPane.showMessageDialog(window, "错误:该路径已被某个扩展存储区占用。", "错误",
JOptionPane.WARNING_MESSAGE);
}
} else {
JOptionPane.showMessageDialog(window, "错误:该路径不可用,必须选择可读写的文件夹。", "错误",
JOptionPane.WARNING_MESSAGE);
}
}
} else {
JFileChooser mainFileSystemPathChooer = new JFileChooser();
mainFileSystemPathChooer.setFileSelectionMode(JFileChooser.DIRECTORIES_ONLY);
mainFileSystemPathChooer.setPreferredSize(fileChooerSize);
FileSystemPath fsp = null;
for (int i = 0; i < SettingWindow.extendStores.size(); i++) {
if (SettingWindow.extendStores.get(i).getIndex() == index) {
fsp = SettingWindow.extendStores.get(i);
mainFileSystemPathChooer.setCurrentDirectory(fsp.getPath());
mainFileSystemPathChooer.setDialogTitle("请选择扩展存储区路径");
if (mainFileSystemPathChooer.showOpenDialog(null) == JFileChooser.APPROVE_OPTION) {
disableAllButtons();
File selectPath = mainFileSystemPathChooer.getSelectedFile();
if (selectPath.isDirectory() && selectPath.canWrite() && selectPath.canRead()) {
if (fsp.getPath().equals(selectPath) || !SettingWindow.extendStores.parallelStream()
.anyMatch(f -> f.getPath().equals(selectPath))) {
String pathName = selectPath.getAbsolutePath();
if (encoder.canEncode(pathName) && pathName.indexOf("\\:") < 0
&& pathName.indexOf("\\\\") < 0) {
fsp.setPath(mainFileSystemPathChooer.getSelectedFile());
} else {
JOptionPane.showMessageDialog(window, INVALID_PATH_ALTER, "错误",
JOptionPane.WARNING_MESSAGE);
}
} else {
JOptionPane.showMessageDialog(window, "错误:该路径已被其他扩展存储区占用。", "错误",
JOptionPane.WARNING_MESSAGE);
}
} else {
JOptionPane.showMessageDialog(window, "错误:该路径不可用,必须选择可读写的文件夹。", "错误",
JOptionPane.WARNING_MESSAGE);
}
}
break;
}
break;
}
}
}

View File

@ -1,5 +1,5 @@
#Generated by Maven Integration for Eclipse
#Thu May 07 17:18:08 CST 2020
#Tue May 12 10:14:44 CST 2020
version=1.0.29-RELEASE
groupId=kohgylw
m2e.projectName=kiftd