Compare commits

...

5 Commits

Author SHA1 Message Date
50cba0557f chore: rename BodyHandler 2024-12-21 22:08:20 +08:00
9e9a1b22b7 chore: 版本号 2024-12-16 12:32:09 +08:00
a8db7cbf88 Release v1.0.3-beta
Release v1.0.3-beta
2024-11-17 17:06:02 +08:00
6a4e425f8a docs: version v1.0.3 2024-11-17 16:22:46 +08:00
09f515025c fix: 修复在AList运行时更新会报错“该文件正在被使用”的问题 2024-11-17 16:21:34 +08:00
8 changed files with 48 additions and 29 deletions

View File

@ -7,11 +7,11 @@
<parent>
<groupId>cn.octopusyan</groupId>
<artifactId>alist-gui</artifactId>
<version>1.0.1</version>
<version>1.0.3</version>
</parent>
<artifactId>gui</artifactId>
<version>${parent.version}</version>
<version>1.0.3</version>
<name>alist-gui</name>
<properties>
@ -141,7 +141,7 @@
<groupId>us.hebi.sass</groupId>
<artifactId>sass-cli-maven-plugin</artifactId>
<configuration>
<sassVersion>1.78.0</sassVersion>
<sassVersion>1.81.0</sassVersion>
<args> <!-- Any argument that should be forwarded to the sass cli -->
<arg>${cssSrcPath}/root.scss:${cssTargetPath}/root.css</arg>
<arg>${cssSrcPath}/root-view.scss:${cssTargetPath}/root-view.css</arg>
@ -191,7 +191,7 @@
<mainClass>cn.octopusyan.alistgui/${exec.mainClass}</mainClass>
<options>
<option>--enable-preview</option>
<!-- <option>-agentlib:jdwp=transport=dt_socket,server=y,suspend=n,address=*:5005</option>-->
<!-- <option>-agentlib:jdwp=transport=dt_socket,server=y,suspend=n,address=*:5005</option>-->
</options>
</configuration>
</execution>
@ -261,7 +261,6 @@
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-resources-plugin</artifactId>
<version>3.3.1</version>
<configuration>
<nonFilteredFileExtensions>
<nonFilteredFileExtension>exe</nonFilteredFileExtension>

View File

@ -41,7 +41,7 @@ public class Application extends javafx.application.Application {
long delay = 0L;
// 更新重启检查
File upgradeFile = new File(Constants.DATA_DIR_PATH + File.separator + new Gui().getReleaseFile());
logger.error("{}{}{}", Constants.DATA_DIR_PATH, File.separator, new Gui().getReleaseFile());
// logger.error("{}{}{}", Constants.DATA_DIR_PATH, File.separator, new Gui().getReleaseFile());
if (upgradeFile.exists()) {
logger.error("upgradeFile.exists");
FileUtil.del(upgradeFile);
@ -165,7 +165,7 @@ public class Application extends javafx.application.Application {
instanceCheckLatch.countDown();
while (true) {
logger.error(STR."====\{instanceId}====");
logger.debug(STR."====\{instanceId}====");
try (
Socket clientSocket = serverSocket.accept();
BufferedReader in = new BufferedReader(

View File

@ -143,24 +143,21 @@ public class AListManager {
ConsoleLog.info(getText("alist.status.stop"));
if (!running.get()) {
ConsoleLog.warning(getText("alist.status.stop.stopped"));
return;
}
util.destroy();
}
static ChangeListener<Boolean> restartListener;
static ChangeListener<Boolean> restartListener = (_, _, run) -> {
if (run) return;
running.removeListener(AListManager.restartListener);
start();
};
public static void restart() {
if (!running.get()) {
start();
} else {
stop();
restartListener = (_, _, run) -> {
if (run) return;
running.removeListener(restartListener);
start();
};
running.addListener(restartListener);
}
}
@ -194,7 +191,7 @@ public class AListManager {
//============================={ private }====================================
/**
* TODO 点击开始时检查 aList 执行文件
* 点击开始时检查 aList 执行文件
*/
private static boolean checkAList() {
if (new File(Constants.ALIST_FILE).exists()) return true;
@ -216,6 +213,11 @@ public class AListManager {
return false;
}
/**
* 开始下载AList
*
* @param version 下载版本号
*/
private static void showDownload(String version) {
String content = STR."""
\{getText("msg.alist.download.notfile")}

View File

@ -1,7 +1,7 @@
package cn.octopusyan.alistgui.manager.http;
import cn.octopusyan.alistgui.enums.ProxySetup;
import cn.octopusyan.alistgui.manager.http.handler.BodyHandler;
import cn.octopusyan.alistgui.manager.http.handler.DownloadBodyHandler;
import cn.octopusyan.alistgui.model.ProxyInfo;
import cn.octopusyan.alistgui.util.JsonUtil;
import com.fasterxml.jackson.databind.JsonNode;
@ -126,7 +126,7 @@ public class HttpUtil {
}
// 下载处理器
var handler = BodyHandler.create(
var handler = DownloadBodyHandler.create(
Path.of(savePath),
StandardOpenOption.CREATE, StandardOpenOption.WRITE
);

View File

@ -21,16 +21,16 @@ import java.util.function.Consumer;
* @author octopus_yan
*/
@Slf4j
public class BodyHandler implements HttpResponse.BodyHandler<Path> {
public class DownloadBodyHandler implements HttpResponse.BodyHandler<Path> {
private final HttpResponse.BodyHandler<Path> handler;
private BiConsumer<Long, Long> consumer;
private BodyHandler(HttpResponse.BodyHandler<Path> handler) {
private DownloadBodyHandler(HttpResponse.BodyHandler<Path> handler) {
this.handler = handler;
}
public static BodyHandler create(Path directory, OpenOption... openOptions) {
return new BodyHandler(HttpResponse.BodyHandlers.ofFileDownload(directory, openOptions));
public static DownloadBodyHandler create(Path directory, OpenOption... openOptions) {
return new DownloadBodyHandler(HttpResponse.BodyHandlers.ofFileDownload(directory, openOptions));
}
@Override

View File

@ -17,6 +17,7 @@ import cn.octopusyan.alistgui.view.alert.AlertUtil;
import cn.octopusyan.alistgui.view.alert.builder.AlertBuilder;
import javafx.application.Platform;
import javafx.beans.property.*;
import javafx.beans.value.ChangeListener;
import lombok.extern.slf4j.Slf4j;
/**
@ -144,8 +145,13 @@ public class AboutViewModule extends BaseViewModel {
Platform.runLater(() -> {
switch (app) {
case AList _ -> {
// 下载完成后,解压并删除文件
DownloadUtil.unzip(app);
if(AListManager.isRunning()) {
AListManager.stop();
AListManager.runningProperty().addListener(updateListener);
} else {
// 下载完成后,解压并删除文件
DownloadUtil.unzip(app);
}
// 设置应用版本
aListVersion.setValue(aListNewVersion.getValue());
AListManager.restart();
@ -163,4 +169,12 @@ public class AboutViewModule extends BaseViewModel {
}).execute();
});
}
static final ChangeListener<Boolean> updateListener = (_, _, run) -> {
if (!run) {
// 下载完成后,解压并删除文件
DownloadUtil.unzip(ConfigManager.aList());
}
AListManager.runningProperty().removeListener(AboutViewModule.updateListener);
};
}

10
pom.xml
View File

@ -6,7 +6,7 @@
<groupId>cn.octopusyan</groupId>
<artifactId>alist-gui</artifactId>
<version>1.0.1</version>
<version>1.0.3</version>
<name>alist-gui</name>
<packaging>pom</packaging>
@ -30,8 +30,6 @@
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding>
<project.version>1.0.1</project.version>
<junit.version>5.10.0</junit.version>
<javafx.version>21.0.4</javafx.version>
<slf4j.version>2.0.16</slf4j.version>
@ -167,6 +165,12 @@
<version>3.13.0</version>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-resources-plugin</artifactId>
<version>3.3.1</version>
</plugin>
<!-- https://github.com/HebiRobotics/sass-cli-maven-plugin -->
<plugin>
<groupId>us.hebi.sass</groupId>

View File

@ -7,11 +7,11 @@
<parent>
<groupId>cn.octopusyan</groupId>
<artifactId>alist-gui</artifactId>
<version>1.0.1</version>
<version>1.0.3</version>
</parent>
<artifactId>upgrade</artifactId>
<version>${parent.version}</version>
<version>1.0.3</version>
<name>upgrade</name>
<properties>