From 8aab4ecbd008e3269f6360a79285383359281f08 Mon Sep 17 00:00:00 2001 From: Kyungrim Park Date: Tue, 14 Nov 2023 17:06:32 +0900 Subject: [PATCH] =?UTF-8?q?#6=20#7=20fix:=20=EB=85=B8=ED=8A=B8=20=EC=B2=A8?= =?UTF-8?q?=EB=B6=80=20=EC=82=AC=EC=A7=84=20=EC=82=AD=EC=A0=9C?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .github/workflows/gradle.yml | 15 +-------------- .../note/application/FileServiceImpl.java | 6 ++++-- .../note/application/NoteServiceImpl.java | 1 + 3 files changed, 6 insertions(+), 16 deletions(-) diff --git a/.github/workflows/gradle.yml b/.github/workflows/gradle.yml index 3b6fa69..b46bc8b 100644 --- a/.github/workflows/gradle.yml +++ b/.github/workflows/gradle.yml @@ -53,17 +53,4 @@ jobs: docker stop $(docker ps -a -q) docker run -d --log-driver=syslog -p 8080:8080 -e SPRING_PROFILES_ACTIVE=prod ${{ secrets.DOCKER_USERNAME }}/yourwriting:latest docker rm $(docker ps --filter 'status=exited' -a -q) - docker image prune -a -f - -# - name: AWS credential 설정 -# uses: aws-actions/configure-aws-credentials@v1 -# with: -# aws-region: ${{ env.AWS_REGION }} -# aws-access-key-id: ${{ secrets.CICD_ACCESS_KEY_ID }} -# aws-secret-access-key: ${{ secrets.CICD_SECRET_ACCESS_KEY }} -# -# - name: S3로 upload -# run: aws deploy push --application-name ${{ env.AWS_CODE_DEPLOY_APPLICATION }} --ignore-hidden-files --s3-location s3://$AWS_S3_BUCKET/yw-cicd/$GITHUB_SHA.zip --source . -# -# - name: EC2에 배포 -# run: aws deploy create-deployment --application-name ${{ env.AWS_CODE_DEPLOY_APPLICATION }} --deployment-config-name CodeDeployDefault.AllAtOnce --deployment-group-name ${{ env.AWS_CODE_DEPLOY_GROUP }} --s3-location bucket=$AWS_S3_BUCKET,key=yw-cicd/$GITHUB_SHA.zip,bundleType=zip \ No newline at end of file + docker image prune -a -f \ No newline at end of file diff --git a/src/main/java/com/realWriting/note/application/FileServiceImpl.java b/src/main/java/com/realWriting/note/application/FileServiceImpl.java index 13d6fa8..3a0e4bd 100644 --- a/src/main/java/com/realWriting/note/application/FileServiceImpl.java +++ b/src/main/java/com/realWriting/note/application/FileServiceImpl.java @@ -104,9 +104,11 @@ public void deleteNoteFileList(Long noteId) { @Override public void deleteFile(String storedName, String path) { String objectKey = path + "/" + storedName; - if (!amazonS3.doesObjectExist(bucketName, objectKey)) { + if (amazonS3.doesObjectExist(bucketName, objectKey)) { + amazonS3.deleteObject(bucketName, objectKey); + } + else { throw new FileException(ErrorCode.FILE_NOT_FOUND); } - amazonS3.deleteObject(bucketName, objectKey); } } diff --git a/src/main/java/com/realWriting/note/application/NoteServiceImpl.java b/src/main/java/com/realWriting/note/application/NoteServiceImpl.java index ea840c4..b09fa5a 100644 --- a/src/main/java/com/realWriting/note/application/NoteServiceImpl.java +++ b/src/main/java/com/realWriting/note/application/NoteServiceImpl.java @@ -77,6 +77,7 @@ public NoteRes.ContentRes updateNote(Long id, NoteReq.ContentReq req) { .update(req.getTitle(), req.getContent()); if (req.getFiles() != null) { + deleteNote(id); uploadFiles(updatedNote, req.getFiles()); }