def delete_attachment(file_id, issue_id): FileInfoService.delete_file(int(file_id), mongo_model=IssueMongoFile) if int(issue_id) != 0: issue = ProjectIssue.objects.get(int(issue_id)) issue.Attachments = issue.Attachments.replace( str(file_id) + ",", "") issue.save()
def copy_package(history): ''' copy release package to release resp ''' result = list() if history.PackageID and not CITaskHistoryService.is_history_archived( history): history_files = list() new_archive = CITaskHistoryService.new_archive( history, history_files) for old_file_id in eval(history.PackageID): file_id = 0 try: file_id = FileInfoService.copy_file( old_file_id, PackgeMongoFile, ReleaseArchiveMongoFile) result.append(file_id) history_files.append(file_id) except Exception as ex: FileInfoService.delete_file(file_id, ReleaseArchiveMongoFile) new_archive.delete() SimpleLogger.exception(ex) result = None if result: file_ids = "" for file_id in history_files: file_ids = file_ids + str(file_id) + "," new_archive.Archives = file_ids new_archive.save() return result
def delete_file(request, package_file_id): result = True try: FileInfoService.delete_file(int(package_file_id), IssueMongoFile) except Exception as ex: result = str(ex) SimpleLogger.exception(ex) return HttpResponse(result)
def update_avatar(user, cached_file_keys): file_list = AccountService.store_cached_file(cached_file_keys) if len(file_list) > 0: if user.extend_info.avatar.isnumeric(): FileInfoService.delete_file(int(user.extend_info.avatar), mongo_model=UCenterMongoFile) user.extend_info.avatar = file_list[0] user.extend_info.save() else: user.extend_info.avatar = file_list[0] user.extend_info.save() return AccountService.get_avatar_url(user, )
def delete_output(stage_historyid): try: outputs = CITaskStepOutput.objects.get_stage_output(int(stage_historyid)) for output in outputs: if output.ProductID: if output.ProductType in (2,3,6): FileInfoService.delete_file(output.ProductID) CITaskHistoryService.clean_temp_file(output.ProductID) if output.ProductType == 1: FileInfoService.delete_file(output.ProductID,mongo_model=BuildLogMongoFile) CITaskHistoryService.clean_temp_file(output.ProductID) if output.ProductType == 5: PackgeMongoFile.objects.delete_value(output.ProductID) output.delete() except Exception as ex: SimpleLogger.exception(ex)
def history_clean_worker(task_historys): for history in task_historys: try: if history.PackageID: for fileid in eval(history.PackageID): FileInfoService.delete_file(fileid) CITaskHistoryService.clean_temp_file(fileid) if history.LogFileID: for fileid in eval(history.LogFileID): FileInfoService.delete_file(fileid) CITaskHistoryService.clean_temp_file(fileid) if history.BuildLogID: FileInfoService.delete_file(history.BuildLogID, mongo_model=BuildLogMongoFile) history.BuildLogID = 0 if history.ChangeLog: PackgeMongoFile.objects.delete_value(history.ChangeLog) history.IsActive = 0 except Exception as ex: SimpleLogger.exception(ex) history.IsActive = 1 continue finally: history.save()
def delete_file(file_id): FileInfoService.delete_file(file_id, mongo_model=FortestingMongoFile)
def delete_attachment(file_id, user_id): FileInfoService.delete_file(int(file_id), mongo_model=UCenterMongoFile)
def delete_file(file_id, mongo_model): FileInfoService.delete_file(file_id, mongo_model)