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()); }