fix(backup): 버려진 내보내기가 uploads 사본을 디스크에 남기던 것 - #100
Merged
Conversation
내보내기는 uploads 전체를 backup_<ts>/files/로 복사한 뒤 tar.gz를 만든다 — 한 번에 원본의 2배가 잡힌다. 정리 핸들러는 있었지만 빌드가 끝난 뒤에야 걸렸다. 빌드는 첨부가 많으면 분 단위고, 그 사이 탭을 닫으면(첫 바이트가 나오기 전이라 빈 흰 화면이다) 정리할 주체가 아직 없어 사본과 아카이브가 그대로 남는다. 누를 때마다 쌓여 실사용에서 디스크를 다 먹었다 (R125). - 요청 끊김을 빌드 시작 전부터 지켜본다. 빌드가 끝났을 때 이미 끊겨 있으면 만든 것을 버리고 소켓을 닫는다 - 프로세스가 죽어 남은 찌꺼기는 sweepStaleBackupWorkspaces()가 기동 시 한 번, 이후 매시간 걷는다. 이름에 박힌 생성 시각으로 나이를 잰다 — mtime은 빌드가 길면 계속 갱신돼 "오래된 것"을 못 고른다. 2시간 미만은 건드리지 않는다 - events/·pets/·tmp/는 대상이 아니다. 테스트로 못박았다 Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
증상
v0.17.3 배포 후 실사용에서 나왔다. 백업을 여러 번 누르니 디스크가 급격히 찼다.
원인
내보내기는 uploads 전체를
backup_<ts>/files/로 복사한 뒤backup_<ts>.tar.gz를 만든다 — 한 번에 원본의 2배가 잡힌다.정리 핸들러는 있었지만 빌드가 끝난 다음에 걸렸다:
빌드는 첨부가 많으면 분 단위고, 그 사이 탭을 닫으면 정리할 주체가 아직 없어 사본과 아카이브가 그대로 남는다. 하필 그 구간이 빈 흰 화면(첫 바이트가 안 나온 상태)이라 닫기 쉽다. 누를 때마다 원본의 2배씩 쌓인다.
copyUploadsForBackup이 이 찌꺼기를 새 아카이브에 담지는 않으므로 백업이 중첩되지는 않는다 — 크기만 문제다.변경
sweepStaleBackupWorkspaces()— 프로세스가 죽어 남은 찌꺼기를 기동 시 한 번, 이후 매시간 걷는다. 이름에 박힌 생성 시각(backup_<Date.now()>)으로 나이를 잰다: mtime은 빌드가 길면 계속 갱신돼 "오래된 것"을 못 고른다. 2시간 미만은 건드리지 않는다 (빌드 중일 수 있다).events/·pets/·tmp/는 대상이 아니다. 테스트로 못박았다.남은 문제
빌드가 원본을 통째로 복사하는 구조 자체는 그대로다.
tar에 소스 디렉터리를 직접 넘기면 사본이 필요 없어지지만, 제외 규칙(작업 디렉터리·이전 아카이브·tmp/)을 tar 쪽으로 옮겨야 해서 이번 범위 밖으로 뒀다.검증
npm test— shared 65, api 249, web 247 통과 (스윕 5건 신규)tsc --noEmit/npm run lint클린 (기존 경고 2건 외)🤖 Generated with Claude Code