diff --git a/src/main/java/kohgylw/kiftd/server/util/ConfigureReader.java b/src/main/java/kohgylw/kiftd/server/util/ConfigureReader.java index 37f828d..59af1dc 100644 --- a/src/main/java/kohgylw/kiftd/server/util/ConfigureReader.java +++ b/src/main/java/kohgylw/kiftd/server/util/ConfigureReader.java @@ -107,6 +107,8 @@ public class ConfigureReader { private boolean enableWebDAV = true;// 是否启用WebDAV功能 private String recycleBinPath;// 删除留档路径 + private boolean tempDirIsInit = false; + private static final int MAX_EXTENDSTORES_NUM = 255;// 扩展存储区最大数目 private static final String[] SYS_ACCOUNTS = { "SYS_IN", "Anonymous", "匿名用户" };// 一些系统的特殊账户 @@ -731,14 +733,19 @@ public class ConfigureReader { return CANT_CREATE_FILE_NODE_PATH; } this.TFPath = this.fileSystemPath + "temporaryfiles" + File.separator; - if (!initTempDir()) { - Printer.instance.print("错误:无法创建临时文件存放区[" + this.TFPath + "]。"); - return CANT_CREATE_TF_PATH; + if (!tempDirIsInit) { + // 如果临时文件夹尚未初始化,则对其进行初始化 + if (!initTempDir()) { + Printer.instance.print("错误:无法创建临时文件存放区[" + this.TFPath + "]。"); + return CANT_CREATE_TF_PATH; + } + // 退出程序时自动初始化(清理)临时文件夹 + Runtime.getRuntime().addShutdownHook(new Thread(() -> { + initTempDir(); + })); + // 标识临时文件夹已经初始化,无需再次初始化 + tempDirIsInit = true; } - // 退出程序时自动初始化(清理)临时文件夹 - Runtime.getRuntime().addShutdownHook(new Thread(() -> { - initTempDir(); - })); if ("true".equals(serverp.getProperty("mysql.enable"))) { dbDriver = "com.mysql.cj.jdbc.Driver"; String url = serverp.getProperty("mysql.url", "127.0.0.1/kift"); diff --git a/src/main/java/kohgylw/kiftd/ui/module/FSViewer.java b/src/main/java/kohgylw/kiftd/ui/module/FSViewer.java index f17ba68..bc44cc2 100644 --- a/src/main/java/kohgylw/kiftd/ui/module/FSViewer.java +++ b/src/main/java/kohgylw/kiftd/ui/module/FSViewer.java @@ -14,6 +14,7 @@ import java.awt.dnd.DropTargetListener; import java.awt.event.MouseEvent; import java.awt.event.MouseListener; import java.io.File; +import java.io.IOException; import java.sql.SQLException; import java.util.ArrayList; import java.util.List; @@ -197,18 +198,21 @@ public class FSViewer extends KiftdDynamicWindow { fsd.show(); }); t.start(); - SwingUtilities.invokeLater(() -> { - try { - FileSystemManager.getInstance().exportTo(folders, nodes, path, type); + try { + FileSystemManager.getInstance().exportTo(folders, nodes, path, type); + SwingUtilities.invokeLater(() -> { fsd.close(); - } catch (Exception e1) { + }); + } catch (Exception e1) { + SwingUtilities.invokeLater(() -> { fsd.close(); + Printer.instance.print(e1.toString()); JOptionPane.showMessageDialog(window, "导出文件时失败,该操作已被中断,未能全部导出。", "错误", JOptionPane.ERROR_MESSAGE); - } - refresh(); - enableAllButtons(); - }); + }); + } + refresh(); + enableAllButtons(); }); } }); @@ -233,19 +237,22 @@ public class FSViewer extends KiftdDynamicWindow { fsd.show(); }); t.start(); - SwingUtilities.invokeLater(() -> { - try { - FileSystemManager.getInstance().delete(selectedFolders.toArray(new String[0]), - selectedNodes.toArray(new String[0])); + try { + FileSystemManager.getInstance().delete(selectedFolders.toArray(new String[0]), + selectedNodes.toArray(new String[0])); + SwingUtilities.invokeLater(() -> { fsd.close(); - } catch (Exception e1) { + }); + } catch (Exception e1) { + SwingUtilities.invokeLater(() -> { fsd.close(); + Printer.instance.print(e1.toString()); JOptionPane.showMessageDialog(window, "删除文件时失败,该操作已被中断,未能全部删除。", "错误", JOptionPane.ERROR_MESSAGE); - } - refresh(); - enableAllButtons(); - }); + }); + } + refresh(); + enableAllButtons(); }); } else { enableAllButtons(); @@ -323,26 +330,33 @@ public class FSViewer extends KiftdDynamicWindow { fsd.show(); }); t.start(); - SwingUtilities.invokeLater(() -> { - try { - boolean exportSuccess = FileSystemManager.getInstance().exportTo( - new String[0], new String[] { n.getFileId() }, previewDir, - null); + try { + boolean exportSuccess = FileSystemManager.getInstance().exportTo( + new String[0], new String[] { n.getFileId() }, previewDir, null); + SwingUtilities.invokeLater(() -> { fsd.close(); if (exportSuccess) { // 如果导出成功,将此文件设置为“只读”并以系统默认方式打开 File pf = new File(previewDir, n.getFileName()); if (pf.isFile() && pf.setReadOnly()) { - Desktop.getDesktop().open(pf); + try { + Desktop.getDesktop().open(pf); + } catch (IOException e1) { + Printer.instance.print(e1.toString()); + JOptionPane.showMessageDialog(window, "无法预览此文件。", "错误", + JOptionPane.ERROR_MESSAGE); + } } } - } catch (Exception e1) { + }); + } catch (Exception e1) { + SwingUtilities.invokeLater(() -> { fsd.close(); Printer.instance.print(e1.toString()); JOptionPane.showMessageDialog(window, "导出文件时失败,该操作已被中断,未能全部导出。", "错误", JOptionPane.ERROR_MESSAGE); - } - }); + }); + } } } } @@ -508,17 +522,16 @@ public class FSViewer extends KiftdDynamicWindow { fsd.show(); }); t.start(); + try { + FileSystemManager.getInstance().importFrom(files, folderId, type); + } catch (FoldersTotalOutOfLimitException e1) { + JOptionPane.showMessageDialog(window, "导入失败,该文件夹内的文件夹数目已达上限,无法导入更多文件夹。", "错误", JOptionPane.ERROR_MESSAGE); + } catch (FilesTotalOutOfLimitException e2) { + JOptionPane.showMessageDialog(window, "导入失败,该文件夹内的文件数目已达上限,无法导入更多文件。", "错误", JOptionPane.ERROR_MESSAGE); + } catch (Exception e3) { + JOptionPane.showMessageDialog(window, "导入失败,无法完成导入,该操作已被中断。", "错误", JOptionPane.ERROR_MESSAGE); + } SwingUtilities.invokeLater(() -> { - try { - FileSystemManager.getInstance().importFrom(files, folderId, type); - } catch (FoldersTotalOutOfLimitException e1) { - JOptionPane.showMessageDialog(window, "导入失败,该文件夹内的文件夹数目已达上限,无法导入更多文件夹。", "错误", - JOptionPane.ERROR_MESSAGE); - } catch (FilesTotalOutOfLimitException e2) { - JOptionPane.showMessageDialog(window, "导入失败,该文件夹内的文件数目已达上限,无法导入更多文件。", "错误", JOptionPane.ERROR_MESSAGE); - } catch (Exception e3) { - JOptionPane.showMessageDialog(window, "导入失败,无法完成导入,该操作已被中断。", "错误", JOptionPane.ERROR_MESSAGE); - } fsd.close(); refresh(); }); diff --git a/target/classes/META-INF/maven/kohgylw/kiftd/pom.properties b/target/classes/META-INF/maven/kohgylw/kiftd/pom.properties index b2c5f73..c93d9af 100644 --- a/target/classes/META-INF/maven/kohgylw/kiftd/pom.properties +++ b/target/classes/META-INF/maven/kohgylw/kiftd/pom.properties @@ -1,5 +1,5 @@ #Generated by Maven Integration for Eclipse -#Fri Dec 29 21:12:51 CST 2023 +#Fri Dec 29 22:48:20 CST 2023 m2e.projectLocation=/Users/kohgylw/Programs/java_workspace/kiftd m2e.projectName=kiftd groupId=kohgylw diff --git a/target/classes/kohgylw/kiftd/server/util/ConfigureReader.class b/target/classes/kohgylw/kiftd/server/util/ConfigureReader.class index b12cbee..5ba0664 100644 Binary files a/target/classes/kohgylw/kiftd/server/util/ConfigureReader.class and b/target/classes/kohgylw/kiftd/server/util/ConfigureReader.class differ diff --git a/target/classes/kohgylw/kiftd/ui/module/FSViewer$1.class b/target/classes/kohgylw/kiftd/ui/module/FSViewer$1.class index 6fd1e82..48b2bd9 100644 Binary files a/target/classes/kohgylw/kiftd/ui/module/FSViewer$1.class and b/target/classes/kohgylw/kiftd/ui/module/FSViewer$1.class differ diff --git a/target/classes/kohgylw/kiftd/ui/module/FSViewer$2.class b/target/classes/kohgylw/kiftd/ui/module/FSViewer$2.class index af4c560..9319449 100644 Binary files a/target/classes/kohgylw/kiftd/ui/module/FSViewer$2.class and b/target/classes/kohgylw/kiftd/ui/module/FSViewer$2.class differ diff --git a/target/classes/kohgylw/kiftd/ui/module/FSViewer$3.class b/target/classes/kohgylw/kiftd/ui/module/FSViewer$3.class index 13682f1..7bfb54f 100644 Binary files a/target/classes/kohgylw/kiftd/ui/module/FSViewer$3.class and b/target/classes/kohgylw/kiftd/ui/module/FSViewer$3.class differ diff --git a/target/classes/kohgylw/kiftd/ui/module/FSViewer.class b/target/classes/kohgylw/kiftd/ui/module/FSViewer.class index dc51cc7..b4e7045 100644 Binary files a/target/classes/kohgylw/kiftd/ui/module/FSViewer.class and b/target/classes/kohgylw/kiftd/ui/module/FSViewer.class differ