From f70d73f13012d3420e6fd32556fc62596e58d46a Mon Sep 17 00:00:00 2001 From: Joe <1264204425@qq.com> Date: Wed, 18 Dec 2024 17:20:39 +0800 Subject: [PATCH] fix: remove extra file --- .github/workflows/build-push.yml | 12 ++-- api/controllers/console/files.py | 99 -------------------------------- 2 files changed, 5 insertions(+), 106 deletions(-) delete mode 100644 api/controllers/console/files.py diff --git a/.github/workflows/build-push.yml b/.github/workflows/build-push.yml index 355c797af7..b180763514 100644 --- a/.github/workflows/build-push.yml +++ b/.github/workflows/build-push.yml @@ -18,6 +18,7 @@ env: DOCKERHUB_TOKEN: ${{ secrets.DOCKERHUB_TOKEN }} DIFY_WEB_IMAGE_NAME: ${{ vars.DIFY_WEB_IMAGE_NAME || 'langgenius/dify-web' }} DIFY_API_IMAGE_NAME: ${{ vars.DIFY_API_IMAGE_NAME || 'langgenius/dify-api' }} + DOCKER_TAG: "v0.8.3-fix1" jobs: build: @@ -66,7 +67,7 @@ jobs: uses: docker/metadata-action@v5 with: images: ${{ env[matrix.image_name_env] }} - + - name: Build Docker image id: build uses: docker/build-push-action@v6 @@ -75,7 +76,7 @@ jobs: platforms: ${{ matrix.platform }} build-args: COMMIT_SHA=${{ fromJSON(steps.meta.outputs.json).labels['org.opencontainers.image.revision'] }} labels: ${{ steps.meta.outputs.labels }} - outputs: type=image,name=${{ env[matrix.image_name_env] }},push-by-digest=true,name-canonical=true,push=true + outputs: type=image,name=${{ env[matrix.image_name_env] }}:${{ env.DOCKER_TAG }},push-by-digest=true,name-canonical=true,push=true cache-from: type=gha,scope=${{ matrix.service_name }} cache-to: type=gha,mode=max,scope=${{ matrix.service_name }} @@ -126,10 +127,7 @@ jobs: with: images: ${{ env[matrix.image_name_env] }} tags: | - type=raw,value=latest,enable=${{ startsWith(github.ref, 'refs/tags/') }} - type=ref,event=branch - type=sha,enable=true,priority=100,prefix=,suffix=,format=long - type=raw,value=${{ github.ref_name }},enable=${{ startsWith(github.ref, 'refs/tags/') }} + type=raw,value=${{ env.DOCKER_TAG }},enable=true - name: Create manifest list and push working-directory: /tmp/digests @@ -139,4 +137,4 @@ jobs: - name: Inspect image run: | - docker buildx imagetools inspect ${{ env[matrix.image_name_env] }}:${{ steps.meta.outputs.version }} + docker buildx imagetools inspect ${{ env[matrix.image_name_env] }}:${{ env.DOCKER_TAG }} diff --git a/api/controllers/console/files.py b/api/controllers/console/files.py deleted file mode 100644 index fe48b0f221..0000000000 --- a/api/controllers/console/files.py +++ /dev/null @@ -1,99 +0,0 @@ -from flask import request -from flask_login import current_user -from flask_restful import Resource, marshal_with -from werkzeug.exceptions import Forbidden - -import services -from configs import dify_config -from constants import DOCUMENT_EXTENSIONS -from controllers.common.errors import FilenameNotExistsError -from controllers.console.wraps import ( - account_initialization_required, - cloud_edition_billing_resource_check, - setup_required, -) -from fields.file_fields import file_fields, upload_config_fields -from libs.login import login_required -from services.file_service import FileService - -from .error import ( - FileTooLargeError, - NoFileUploadedError, - TooManyFilesError, - UnsupportedFileTypeError, -) - -PREVIEW_WORDS_LIMIT = 3000 - - -class FileApi(Resource): - @setup_required - @login_required - @account_initialization_required - @marshal_with(upload_config_fields) - def get(self): - return { - "file_size_limit": dify_config.UPLOAD_FILE_SIZE_LIMIT, - "batch_count_limit": dify_config.UPLOAD_FILE_BATCH_LIMIT, - "image_file_size_limit": dify_config.UPLOAD_IMAGE_FILE_SIZE_LIMIT, - "video_file_size_limit": dify_config.UPLOAD_VIDEO_FILE_SIZE_LIMIT, - "audio_file_size_limit": dify_config.UPLOAD_AUDIO_FILE_SIZE_LIMIT, - "workflow_file_upload_limit": dify_config.WORKFLOW_FILE_UPLOAD_LIMIT, - }, 200 - - @setup_required - @login_required - @account_initialization_required - @marshal_with(file_fields) - @cloud_edition_billing_resource_check("documents") - def post(self): - file = request.files["file"] - source = request.form.get("source") - - if "file" not in request.files: - raise NoFileUploadedError() - - if len(request.files) > 1: - raise TooManyFilesError() - - if not file.filename: - raise FilenameNotExistsError - - if source == "datasets" and not current_user.is_dataset_editor: - raise Forbidden() - - if source not in {"datasets", None}: - source = None - - try: - upload_file = FileService.upload_file( - filename=file.filename, - content=file.read(), - mimetype=file.mimetype, - user=current_user, - source=source, - ) - except services.errors.file.FileTooLargeError as file_too_large_error: - raise FileTooLargeError(file_too_large_error.description) - except services.errors.file.UnsupportedFileTypeError: - raise UnsupportedFileTypeError() - - return upload_file, 201 - - -class FilePreviewApi(Resource): - @setup_required - @login_required - @account_initialization_required - def get(self, file_id): - file_id = str(file_id) - text = FileService.get_file_preview(file_id) - return {"content": text} - - -class FileSupportTypeApi(Resource): - @setup_required - @login_required - @account_initialization_required - def get(self): - return {"allowed_extensions": DOCUMENT_EXTENSIONS}