-
Notifications
You must be signed in to change notification settings - Fork 24
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix: 更新条目时对于https的封面下载失败时没有保留原封面不更新 (#718)
* build: upgrade to v0.18.3 * fix: 更新条目时对于https的封面下载失败时没有保留原封面不更新
- Loading branch information
Showing
4 changed files
with
49 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1 @@ | ||
version=0.18.2 | ||
version=0.18.3 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
31 changes: 31 additions & 0 deletions
31
server/src/main/java/run/ikaros/server/infra/utils/ByteArrUtils.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
package run.ikaros.server.infra.utils; | ||
|
||
import java.nio.charset.StandardCharsets; | ||
|
||
public class ByteArrUtils { | ||
/** | ||
* 判断字节数组为二进制数据. | ||
*/ | ||
public static boolean isBinaryData(byte[] data) { | ||
for (byte b : data) { | ||
if (b < 32 && b != 9 && b != 10 && b != 13) { | ||
return true; // 存在控制字符,可能是二进制数据 | ||
} | ||
} | ||
return false; // 没有控制字符,可能是字符串 | ||
} | ||
|
||
/** | ||
* 判断字节数组为字符串数据. | ||
*/ | ||
public static boolean isStringData(byte[] data) { | ||
try { | ||
String str = new String(data, StandardCharsets.UTF_8); | ||
// 检查解码后的字符串是否包含非可打印字符 | ||
return str.chars().allMatch(c -> c >= 32 || c == 9 || c == 10 || c == 13); | ||
} catch (Exception e) { | ||
return false; // 解码失败,认为是二进制数据 | ||
} | ||
} | ||
|
||
} |