From e3c0518cfbbc095abab988d425040d58da9d3e3e Mon Sep 17 00:00:00 2001 From: fit2bot <68588906+fit2bot@users.noreply.github.com> Date: Thu, 14 Dec 2023 19:44:53 +0800 Subject: [PATCH] =?UTF-8?q?perf:=20=E4=B8=8A=E4=BC=A0=E7=9B=AE=E6=A0=87?= =?UTF-8?q?=E7=9B=AE=E5=BD=95=E6=8C=87=E5=AE=9A=E5=9C=A8/tmp=E4=B8=8B=20(#?= =?UTF-8?q?12334)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Co-authored-by: wangruidong <940853815@qq.com> --- apps/ops/ansible/runner.py | 2 +- apps/ops/api/job.py | 2 +- apps/ops/models/job.py | 7 ++----- 3 files changed, 4 insertions(+), 7 deletions(-) diff --git a/apps/ops/ansible/runner.py b/apps/ops/ansible/runner.py index 47af111e5..c5fee5fd9 100644 --- a/apps/ops/ansible/runner.py +++ b/apps/ops/ansible/runner.py @@ -93,7 +93,7 @@ class UploadFileRunner: self.cb = DefaultCallback() upload_file_dir = safe_join(settings.DATA_DIR, 'job_upload_file') self.src_paths = safe_join(upload_file_dir, str(job_id)) - self.dest_path = dest_path + self.dest_path = safe_join("/tmp", dest_path) def run(self, verbosity=0, **kwargs): verbosity = get_ansible_log_verbosity(verbosity) diff --git a/apps/ops/api/job.py b/apps/ops/api/job.py index 90c5edbc3..3b07e850d 100644 --- a/apps/ops/api/job.py +++ b/apps/ops/api/job.py @@ -68,7 +68,7 @@ class JobViewSet(OrgBulkModelViewSet): def get_queryset(self): queryset = super().get_queryset() - queryset = queryset.filter(creator=self.request.user) + queryset = queryset.filter(creator=self.request.user).exclude(type=Types.upload_file) if self.action != 'retrieve': return queryset.filter(instant=False) return queryset diff --git a/apps/ops/models/job.py b/apps/ops/models/job.py index 358c37136..bf460232f 100644 --- a/apps/ops/models/job.py +++ b/apps/ops/models/job.py @@ -381,11 +381,8 @@ class JobExecution(JMSOrgBaseModel): elif self.current_job.type == Types.upload_file: job_id = self.current_job.id args = json.loads(self.current_job.args) - dst_path = args.get('dst_path') - if dst_path: - runner = UploadFileRunner(self.inventory_path, job_id, dst_path) - else: - raise ValueError("dst_path is null") + dst_path = args.get('dst_path', '/') + runner = UploadFileRunner(self.inventory_path, job_id, dst_path) else: raise Exception("unsupported job type") return runner