Search in sources :

Example 1 with JSON

use of com.acgist.snail.format.JSON in project snail by acgist.

the class SystemContext method latestRelease.

/**
 * <p>判断是不是最新版本</p>
 *
 * @return 是不是最新版本
 */
public static final boolean latestRelease() {
    try {
        // 本地版本:1.0.0
        final String version = SystemConfig.getVersion();
        final var body = HttpClient.newInstance(SystemConfig.getLatestRelease()).get().responseToString();
        final JSON json = JSON.ofString(body);
        // 最新版本:1.0.0
        final String latestVersion = json.getString("tag_name");
        LOGGER.debug("版本信息:{}-{}", version, latestVersion);
        return latestVersion.equals(version);
    } catch (NetException e) {
        LOGGER.error("获取版本信息异常", e);
    }
    return true;
}
Also used : NetException(com.acgist.snail.context.exception.NetException) JSON(com.acgist.snail.format.JSON)

Aggregations

NetException (com.acgist.snail.context.exception.NetException)1 JSON (com.acgist.snail.format.JSON)1