Skip to content

Commit

Permalink
fix(backend): 上传文件为空的问题 #3346
Browse files Browse the repository at this point in the history
  • Loading branch information
zhangzhw8 committed Feb 23, 2024
1 parent 54b0815 commit 3460de9
Show file tree
Hide file tree
Showing 4 changed files with 13 additions and 13 deletions.
18 changes: 9 additions & 9 deletions dbm-ui/backend/dbm_init/medium/handlers.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@
an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the
specific language governing permissions and limitations under the License.
"""
import hashlib
import json
import logging
import os
Expand Down Expand Up @@ -153,14 +152,15 @@ def upload_medium(self, path, bkrepo_tmp_dir):
file_path_bkrepo = file_path.split(file_path.rsplit("/", 4)[0])[1]
print("upload file: %s -> %s", file_path, file_path_bkrepo)
with open(file_path, "rb") as f:
# 如果当前版本不存在,则更新介质
if not self.storage.listdir(file_path_bkrepo.rsplit("/", 1)[0])[1]:
self.storage.save(file_path_bkrepo, f)
# 如果文件md5不相等,则更新介质
bkrepo_file_md5 = self.storage.listdir(file_path_bkrepo.rsplit("/", 1)[0])[1][0]["md5"]
pkg_file_md5 = hashlib.md5(f.read()).hexdigest()
if bkrepo_file_md5 != pkg_file_md5:
self.storage.save(file_path_bkrepo, f)
# # 如果当前版本不存在,则更新介质
# if not self.storage.listdir(file_path_bkrepo.rsplit("/", 1)[0])[1]:
# self.storage.save(file_path_bkrepo, f)
# # 如果文件md5不相等,则更新介质
# bkrepo_file_md5 = self.storage.listdir(file_path_bkrepo.rsplit("/", 1)[0])[1][0]["md5"]
# pkg_file_md5 = hashlib.md5(f.read()).hexdigest()
# if bkrepo_file_md5 != pkg_file_md5:
# TODO:这里执行 f.read() 后再进行 storage.save 会导致上传到 bkrepo 的文件为空,待进一步排查
self.storage.save(file_path_bkrepo, f)

def sync_from_bkrepo(self, db_type):
"""将制品库文件同步到dbm"""
Expand Down
4 changes: 2 additions & 2 deletions helm-charts/bk-dbm/Chart.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -79,5 +79,5 @@ dependencies:
description: A Helm chart for bk-dbm
name: bk-dbm
type: application
version: 1.3.0-alpha.38
appVersion: 1.3.0-alpha.38
version: 1.3.0-alpha.39
appVersion: 1.3.0-alpha.39
2 changes: 1 addition & 1 deletion helm-charts/bk-dbm/charts/dbconfig/Chart.yaml
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
apiVersion: v2
appVersion: 0.0.1-alpha.77
appVersion: 0.0.1-alpha.78
description: A Helm chart for dbconfig
name: dbconfig
type: application
Expand Down
2 changes: 1 addition & 1 deletion helm-charts/bk-dbm/charts/dbm/Chart.yaml
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
apiVersion: v2
appVersion: 1.3.0-alpha.428
appVersion: 1.3.0-alpha.431
description: A Helm chart for dbm
name: dbm
type: application
Expand Down

0 comments on commit 3460de9

Please sign in to comment.