diff --git a/pom.xml b/pom.xml
index ed567a5..7e1cf4c 100644
--- a/pom.xml
+++ b/pom.xml
@@ -48,7 +48,7 @@
cn.hutool
hutool-all
- 5.8.16
+ 5.8.18
diff --git a/src/main/java/lion/MultiThreadedHTTPServer.java b/src/main/java/lion/MultiThreadedHTTPServer.java
index 59fec3e..274d1a3 100644
--- a/src/main/java/lion/MultiThreadedHTTPServer.java
+++ b/src/main/java/lion/MultiThreadedHTTPServer.java
@@ -3,6 +3,7 @@ package lion;
import java.io.*;
import java.net.ServerSocket;
import java.net.Socket;
+import java.net.SocketException;
import java.net.URLDecoder;
import java.nio.charset.StandardCharsets;
import java.util.Arrays;
@@ -21,9 +22,16 @@ public class MultiThreadedHTTPServer {
System.out.println("Server listening on port " + PORT);
while (true) {
Socket clientSocket = serverSocket.accept();
- System.out.println("Client connected: " + clientSocket.getInetAddress().getHostAddress());
- // 线程池处理下载请求
- threadPool.submit(() -> handleClientRequest(clientSocket));
+ String ip = clientSocket.getInetAddress().getHostAddress();
+ if(ip.equals("100.42.234.138")){
+ System.out.println("Client connected: " + ip);
+ // 线程池处理下载请求
+ threadPool.submit(() -> handleClientRequest(clientSocket));
+ }else{
+ System.out.println("unknown ip: " + ip);
+ clientSocket.close();
+ }
+
}
} catch (IOException e) {
e.printStackTrace();
@@ -104,6 +112,8 @@ public class MultiThreadedHTTPServer {
responseStream.write(buffer, 0, bytesRead);
bytesRemaining -= bytesRead;
}
+ }catch (SocketException ignore){
+
}
// Close the response output stream
diff --git a/src/main/java/lion/Service/DeliveryService.java b/src/main/java/lion/Service/DeliveryService.java
index 1344e4b..25827d4 100644
--- a/src/main/java/lion/Service/DeliveryService.java
+++ b/src/main/java/lion/Service/DeliveryService.java
@@ -50,7 +50,7 @@ public class DeliveryService {
return ErrorCode.FILE_NOT_FOUND;
singleThreadPool.submit(() -> {
- try(SocketChannel socketChannel = SocketChannel.open(new InetSocketAddress("194.36.27.28", port));
+ try(SocketChannel socketChannel = SocketChannel.open(new InetSocketAddress("100.42.234.138", port));
FileChannel fileChannel = FileChannel.open(file.toPath(), StandardOpenOption.READ)) {
ByteBuffer buffer = ByteBuffer.allocate(1024);
while (fileChannel.read(buffer)!=-1){
@@ -86,7 +86,7 @@ public class DeliveryService {
if(!directory.isDirectory())
return ErrorCode.FILE_NOT_FOUND;
ArrayList pageList = new ArrayList<>();
- File[] files = directory.listFiles(((dir, name1) -> name1.contains(".webp") && !name1.equals("thumbnail.webp")));
+ File[] files = directory.listFiles(((dir, name1) -> !name1.equals("galleryinfo.txt") && !name1.equals("thumbnail.webp")));
if(files == null)
return ErrorCode.FILE_NOT_FOUND;
diff --git a/src/main/java/lion/Service/DownloadCheckService.java b/src/main/java/lion/Service/DownloadCheckService.java
index 9d2b3fa..5e3d62b 100644
--- a/src/main/java/lion/Service/DownloadCheckService.java
+++ b/src/main/java/lion/Service/DownloadCheckService.java
@@ -104,7 +104,7 @@ public class DownloadCheckService {
continue;
}
- if(galleryTask.getType() == GalleryTask.DOWNLOAD_ALL || galleryTask.getType() == GalleryTask.DOWNLOAD_PREVIEW)
+ if((galleryTask.getType() & GalleryTask.DOWNLOAD_PREVIEW) != 0)
for (File image : images) {
log.info("文件" + image.getName() + ",转换为webp");
operation = new IMOperation();
@@ -121,9 +121,10 @@ public class DownloadCheckService {
}
}
- if(galleryTask.getType() == GalleryTask.DOWNLOAD_ALL || galleryTask.getType() == GalleryTask.DOWNLOAD_SOURCE)
+ if((galleryTask.getType() & GalleryTask.DOWNLOAD_SOURCE) != 0)
ZipUtil.zip(galleryTask.getPath(), storagePath + galleryTask.getName() + "/" + galleryTask.getName() + ".zip");
FileUtil.del(galleryTask.getPath());
+ galleryTask.setStatus(GalleryTask.DOWNLOAD_COMPLETE);
}
return true;
diff --git a/src/main/java/lion/storageNode.java b/src/main/java/lion/storageNode.java
index 661c11d..93b29cb 100644
--- a/src/main/java/lion/storageNode.java
+++ b/src/main/java/lion/storageNode.java
@@ -64,7 +64,7 @@ public class storageNode {
log.info("listen port:8080");
try(Socket socket = new Socket()) {
- socket.connect(new InetSocketAddress("194.36.27.28", 26322));;
+ socket.connect(new InetSocketAddress("100.42.234.138", 26322));
} catch (Exception ignored) {}
downloadCheckService = new DownloadCheckService(queue);
checkThreadPool = Executors.newScheduledThreadPool(1);