-
Notifications
You must be signed in to change notification settings - Fork 57
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
feature: 文件分发 & 存储 支持制品库 #93
Conversation
Codecov Report
@@ Coverage Diff @@
## V2.1.348rc #93 +/- ##
==============================================
+ Coverage 58.89% 59.38% +0.49%
==============================================
Files 396 410 +14
Lines 25970 26510 +540
==============================================
+ Hits 15295 15743 +448
- Misses 10675 10767 +92
Continue to review full report at Codecov.
|
@@ -29,7 +29,7 @@ def handle(self, *args, **options): | |||
# 接入点配置的nginx路径 | |||
nginx_paths = [ap.nginx_path for ap in AccessPoint.objects.all() if ap.nginx_path] | |||
# 默认nginx路径 | |||
nginx_paths.append(settings.NGINX_DOWNLOAD_PATH) | |||
nginx_paths.append(settings.DOWNLOAD_PATH) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
43行 这里没改造,还是用的本地文件copy,应该调整为storage.save
apps/backend/plugin/serializers.py
Outdated
@@ -287,6 +310,15 @@ def validate(self, data): | |||
creator = serializers.CharField() | |||
bk_app_code = serializers.CharField() | |||
|
|||
def validate(self, attrs): | |||
if attrs["category"] not in DownloadRecord.CATEGORY_TASK_DICT: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
这个为什么不直接在serializer字段上加choices
) | ||
pkg_parse_result.update( | ||
{ | ||
"pkg_abs_path": package_info["pkg_relative_path"], |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
abs_path
,relative_path
迷惑性
apps/backend/plugin/views.py
Outdated
try: | ||
if files.md5sum(file_obj=storage.open(name=file_path)) != md5: | ||
raise ValidationError(_("上传文件MD5校验失败,请确认重试")) | ||
except Exception as e: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
这里的异常捕获会把上面的 MD5校验异常捕获,抛出文件不存在的异常
upload_result = self.client.post( | ||
path="/backend/package/upload/", | ||
data={ | ||
**self.API_AUTH_PARAMS, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
**self.API_AUTH_PARAMS
每个请求都需要的话,可以考虑在 PluginBaseTestCase
里重写self.client
,请求时在参数里加上 API_AUTH_PARAMS
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
或者在更上层的BaseTestCase基类中去实现
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
apps.utils.unittest.base.CustomAPIClient
加了 common_request_data
,上层 TestCase
在 setUp
等钩子通过self.client.common_request_data
设置通用请求
) -> List[Dict[str, Any]]: | ||
|
||
# 获取或创建文件源 | ||
file_source_obj = BkJobFileSourceManager.get_or_create_file_source( |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
每次handle的时候都去检查或创建,会带来额外的性能消耗?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
每次handle的时候都去检查或创建,会带来额外的性能消耗?
已加缓存
0217976
to
cc9d915
Compare
60caa11
to
44e2e8b
Compare
44e2e8b
to
8fa56f5
Compare
No description provided.