Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

refactor: npm远程仓库优化 #1168 #1173

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

scplsy
Copy link
Collaborator

@scplsy scplsy commented Sep 15, 2023

issue:

  1. npm远程仓库优化 #1168

描述:

  1. fix: 修复无法请求{package}-{version}.json文件的问题
  2. perf: 版本元数据文件{package}-{version}.json永久优先从缓存读取;package.json文件仅在未开启缓存或缓存过期后再从代理源请求
  3. fix: 修复远程仓库ArtifactChannel错误的问题
  4. fix: npm远程仓库查询元数据,返回格式不是json格式时,抛出异常报系统繁忙
  5. refactor: 重复逻辑代码复用

@@ -177,7 +175,7 @@ abstract class RemoteRepository : AbstractArtifactRepository() {
val size = artifactFile.getSize()
val artifactStream = artifactFile.getInputStream().artifactStream(Range.full(size))
val node = cacheArtifactFile(context, artifactFile)
return ArtifactResource(artifactStream, context.artifactInfo.getResponseName(), node, ArtifactChannel.LOCAL)
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

这里是本地下载,为什么要改成PROXY呢

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

这里是onDownloadResponse方法,都是远程下载的

@@ -115,21 +115,19 @@ abstract class RemoteRepository : AbstractArtifactRepository() {
/**
* 尝试读取缓存的远程构件
*/
fun getCacheArtifactResource(context: ArtifactDownloadContext): ArtifactResource? {
open fun getCacheArtifactResource(context: ArtifactContext): ArtifactResource? {
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

这里是为什么要把ArtifactDownloadContext换成ArtifactContext呢,这里应该是处理下载上下文

Copy link
Collaborator Author

@scplsy scplsy Sep 19, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

查询元数据文件时使用的是ArtifactQueryContext,也会读取和缓存文件,且其它类型仓库也有类似的行为,因此扩大了这个方法的使用范围。

@cnlkl cnlkl added the wip work in progess label Nov 2, 2023
@scplsy scplsy self-assigned this Dec 21, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
wip work in progess
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants