Compare commits
83
Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
1531c2498b | ||
|
|
60e80dda87 | ||
|
|
445da5f093 | ||
|
|
b62c7f2495 | ||
|
|
2b7c94e7c3 | ||
|
|
470b586085 | ||
|
|
3d0f9b9d1b | ||
|
|
634de93ffe | ||
|
|
996830bec7 | ||
|
|
cd88f94277 | ||
|
|
47970cd8ff | ||
|
|
ada3fbf9cb | ||
|
|
f6c99bd262 | ||
|
|
1241f19c16 | ||
|
|
d7a7a88232 | ||
|
|
7743b1bab2 | ||
|
|
982b1ee3e4 | ||
|
|
05e28c2c6d | ||
|
|
c18d0e8a9f | ||
|
|
1b221b13d1 | ||
|
|
135996ce19 | ||
|
|
6b85cddede | ||
|
|
e486f850f2 | ||
|
|
76c2f3a5fd | ||
|
|
bb542e7510 | ||
|
|
eba4461381 | ||
|
|
f5ad238015 | ||
|
|
4bdb24e9ac | ||
|
|
425922fd04 | ||
|
|
d65424e5bf | ||
|
|
2a35793baf | ||
|
|
d22df698b6 | ||
|
|
1771bf9909 | ||
|
|
15d69f9361 | ||
|
|
2b4089ef59 | ||
|
|
20c3e1f422 | ||
|
|
3b19d9e930 | ||
|
|
5fd11e9caf | ||
|
|
0b98dcdfe9 | ||
|
|
b373cbbe46 | ||
|
|
acd97c7b9b | ||
|
|
118bdb1666 | ||
|
|
944de228f7 | ||
|
|
25c9cd4dfc | ||
|
|
882cd226ec | ||
|
|
feb4d7af66 | ||
|
|
d75ab1ed5f | ||
|
|
a501eb7443 | ||
|
|
19941d9480 | ||
|
|
cd3d522d4f | ||
|
|
181c5078e9 | ||
|
|
e97f46e6b4 | ||
|
|
c0f89deb83 | ||
|
|
ce695463d3 | ||
|
|
83c683d473 | ||
|
|
9555474b0b | ||
|
|
a150f9e017 | ||
|
|
ecd2fa1c33 | ||
|
|
e3236d262d | ||
|
|
c8e2e16ba5 | ||
|
|
99b44faf09 | ||
|
|
b3e3cbf84b | ||
|
|
0aee11d824 | ||
|
|
fcf358a768 | ||
|
|
619369104c | ||
|
|
4f1408b9d0 | ||
|
|
029eea70cc | ||
|
|
22b1e65385 | ||
|
|
2170c48763 | ||
|
|
c2d1c48aae | ||
|
|
e14958c643 | ||
|
|
da288338cd | ||
|
|
ea430f2468 | ||
|
|
f76f79744a | ||
|
|
19daaff907 | ||
|
|
db94d8f932 | ||
|
|
53618fe362 | ||
|
|
523edffc4e | ||
|
|
c7ddb1a8b0 | ||
|
|
45c9fc814a | ||
|
|
407dc13ac4 | ||
|
|
0c06bf16c2 | ||
|
|
1db39e77d3 |
@@ -11,7 +11,7 @@
|
||||
|
||||
<groupId>com.imyeyu.timiserverapi</groupId>
|
||||
<artifactId>TimiServerAPI</artifactId>
|
||||
<version>1.0.76</version>
|
||||
<version>1.0.72</version>
|
||||
<packaging>jar</packaging>
|
||||
<name>TimiServerAPI</name>
|
||||
<description>imyeyu.com API</description>
|
||||
|
||||
@@ -42,12 +42,6 @@ public class AppVersionService {
|
||||
/// 内置包版本标识
|
||||
public static final String BUILTIN_VERSION = "builtin";
|
||||
|
||||
/// 首个能处理外壳安装包的 Web 包版本
|
||||
///
|
||||
/// 更早的包不认识 shell 标记,只会把 url 当热更 zip 交给插件解压,拿到 APK 必然失败。
|
||||
/// 通道指向原生包时,低于这个版本的设备改为下发热更包,先把它升到能自升级为止
|
||||
public static final String SHELL_AWARE_VERSION = "1.3.2";
|
||||
|
||||
/// 更新日志最多返回的版本条数
|
||||
public static final int MAX_NOTES = 20;
|
||||
|
||||
@@ -78,17 +72,10 @@ public class AppVersionService {
|
||||
}
|
||||
int currentCode = parseInt(req.getVersionCode(), 0);
|
||||
if (release.getKind() == AppRelease.Kind.NATIVE) {
|
||||
// 低于外壳升级能力的包拿不动安装包,先补热更,否则它会把 APK 当 zip 解
|
||||
boolean shellAware = 0 <= compareVersion(currentVersion, SHELL_AWARE_VERSION);
|
||||
AppRelease nativeTarget = shellAware ? resolveNative(release, currentCode) : null;
|
||||
if (nativeTarget != null) {
|
||||
return buildResponse(nativeTarget, Boolean.TRUE.equals(nativeTarget.getMandatory()), true);
|
||||
}
|
||||
// 装不了安装包,或壳已经是最新:热更不能因为通道被原生包占着就断流
|
||||
AppRelease bundle = resolveLatestBundle(product, currentCode, currentVersion, req.getDeviceId());
|
||||
return bundle == null
|
||||
AppRelease target = resolveNative(release, currentCode);
|
||||
return target == null
|
||||
? AppUpdateCheckResponse.none(currentVersion)
|
||||
: buildResponse(bundle, false, false);
|
||||
: buildResponse(target, Boolean.TRUE.equals(target.getMandatory()), true);
|
||||
}
|
||||
AppRelease target = resolveBundle(release, product, currentCode, currentVersion, req.getDeviceId());
|
||||
return target == null
|
||||
@@ -114,11 +101,8 @@ public class AppVersionService {
|
||||
return new AppUpdateNotesResponse(null, Collections.emptyList());
|
||||
}
|
||||
AppRelease target = resolveChannelRelease(product, req);
|
||||
// 安装包不属于更新日志:通道指向原生包时,改用最新发布的热更包做上界
|
||||
// 原生包更新走安装包,与热更日志无关
|
||||
if (target == null || target.getKind() == AppRelease.Kind.NATIVE) {
|
||||
target = latestPublishedBundle(product);
|
||||
}
|
||||
if (target == null) {
|
||||
return new AppUpdateNotesResponse(null, Collections.emptyList());
|
||||
}
|
||||
// 当前版本不低于通道版本:已是最新,或回滚后反而超前
|
||||
@@ -233,62 +217,6 @@ public class AppVersionService {
|
||||
return release;
|
||||
}
|
||||
|
||||
/// 查询设备此刻可用的最新热更包
|
||||
///
|
||||
/// 通道指向原生包时用它兜底:通道是单指针,原生包一上线热更就停发,
|
||||
/// 而低于 SHELL_AWARE_VERSION 的设备又拿不动安装包,只能靠这里把它先升上去。
|
||||
/// 只认 PUBLISHED 且版本高于当前包的记录,不会降级,最坏情况是多升一次。
|
||||
///
|
||||
/// @param product 产品
|
||||
/// @param currentCode 当前原生 versionCode
|
||||
/// @param currentVersion 当前 Web 包版本
|
||||
/// @param deviceId 设备标识
|
||||
/// @return 可用热更包,没有则返回 null
|
||||
private AppRelease resolveLatestBundle(
|
||||
AppProduct product,
|
||||
int currentCode,
|
||||
String currentVersion,
|
||||
String deviceId
|
||||
) {
|
||||
AppRelease latest = null;
|
||||
for (AppRelease item : releaseMapper.selectPublished(product.getId(), AppRelease.Kind.BUNDLE)) {
|
||||
if (item.getMinVersionCode() != null && currentCode < item.getMinVersionCode()) {
|
||||
continue;
|
||||
}
|
||||
if (item.getMaxVersionCode() != null && item.getMaxVersionCode() < currentCode) {
|
||||
continue;
|
||||
}
|
||||
// 同级或更低不下发,避免把设备降回去
|
||||
if (0 >= compareVersion(item.getVersionName(), currentVersion)) {
|
||||
continue;
|
||||
}
|
||||
if (!hitGray(item.getGrayPermille(), deviceId, product.getAppKey())) {
|
||||
continue;
|
||||
}
|
||||
if (latest == null || 0 < compareVersion(item.getVersionName(), latest.getVersionName())) {
|
||||
latest = item;
|
||||
}
|
||||
}
|
||||
return latest;
|
||||
}
|
||||
|
||||
/// 取最近一次发布的热更包
|
||||
///
|
||||
/// 通道指向原生包时,更新日志没有「通道版本」可用,改用这里兜底。
|
||||
/// 日志是「这个产品最近发了什么」,与设备能不能装无关,所以不套灰度与兼容区间
|
||||
///
|
||||
/// @param product 产品
|
||||
/// @return 版本最高的已发布热更包,没有则返回 null
|
||||
private AppRelease latestPublishedBundle(AppProduct product) {
|
||||
AppRelease latest = null;
|
||||
for (AppRelease item : releaseMapper.selectPublished(product.getId(), AppRelease.Kind.BUNDLE)) {
|
||||
if (latest == null || 0 < compareVersion(item.getVersionName(), latest.getVersionName())) {
|
||||
latest = item;
|
||||
}
|
||||
}
|
||||
return latest;
|
||||
}
|
||||
|
||||
/// 判断设备是否命中灰度
|
||||
///
|
||||
/// @param grayPermille 灰度比例,万分比
|
||||
@@ -533,7 +461,7 @@ public class AppVersionService {
|
||||
if (release.getStatus() == AppRelease.Status.PUBLISHED) {
|
||||
throw new IllegalArgumentException("已发布的版本不能删除,请先撤回");
|
||||
}
|
||||
releaseMapper.delete(releaseId);
|
||||
releaseMapper.destroy(releaseId);
|
||||
log("APP_RELEASE_DELETE", releaseId);
|
||||
}
|
||||
|
||||
|
||||
@@ -260,9 +260,7 @@ public class AttachmentController {
|
||||
}
|
||||
|
||||
private void setDownloadHeader(Attachment attachment) throws UnsupportedEncodingException {
|
||||
// 路径带 /download 就强制下载:/download/{id} 的结尾是 id,用 endsWith 匹配不到
|
||||
boolean download = TimiSpring.getRequest().getRequestURI().contains("/download");
|
||||
if (attachment != null && download && attachment.getName() != null) {
|
||||
if (attachment != null && TimiSpring.getRequest().getRequestURI().endsWith("/download") && attachment.getName() != null) {
|
||||
TimiSpring.getResponse().setHeader("Content-Disposition", Network.getFileDownloadHeader(attachment.getName()));
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user