Skip to content

Comments

unsync copy 디렉토리 안전성 개선#25

Merged
laggu merged 1 commit intodevelopfrom
gh-025
Feb 18, 2026
Merged

unsync copy 디렉토리 안전성 개선#25
laggu merged 1 commit intodevelopfrom
gh-025

Conversation

@laggu
Copy link
Owner

@laggu laggu commented Feb 18, 2026

설명

unsync의 copy 모드에서 디렉토리 볼륨 처리와 삭제 방식이 파일 중심으로 구현되어 있어, 디렉토리 케이스에서 제거 실패 또는 의도치 않은 스킵이 발생할 수 있습니다.

핵심 문제:

  • copy 모드 removable 검증이 verifyHash(파일 해시) 고정 경로로 되어 있음
  • 실제 대상이 디렉토리인 경우 verifyDirHash 경로를 타지 않음
  • 삭제 시 os.Remove를 사용해 비어있지 않은 디렉토리 제거 실패 가능

영향 받는 파일

  • internal/gitvolume/unsync.go
  • internal/gitvolume/fs.go
  • internal/gitvolume/unsync_test.go

재현 방법

  1. mode: copy로 디렉토리를 마운트하도록 git-volume.yaml 설정
  2. git volume sync 실행
  3. git volume unsync 실행
  4. 디렉토리 검증/삭제 단계에서 실패하거나 스킵되는지 확인

권장 수정

  • checkRemovable에서 source/target 타입을 확인해 분기
    • 파일: verifyHash
    • 디렉토리: verifyDirHash
  • removeVolume에서 디렉토리 대상은 os.RemoveAll(또는 타입 분기) 사용
  • copy 디렉토리 시나리오 테스트 추가
    • 정상 제거
    • 수정된 디렉토리 스킵
    • source 누락 시 안전 스킵

변경 사항


Closes #25

@gemini-code-assist
Copy link

Summary of Changes

Hello @laggu, I'm Gemini Code Assist1! I'm currently reviewing this pull request and will post my feedback shortly. In the meantime, here's a summary to help you and other reviewers quickly get up to speed!

unsync 명령의 copy 모드에서 디렉토리 볼륨 처리 시 발생하던 안정성 문제를 해결하기 위한 변경사항입니다. 기존에는 디렉토리의 콘텐츠 검증 및 제거 로직이 파일에 맞춰져 있어, 비어있지 않은 디렉토리 제거 실패나 의도치 않은 스킵이 발생할 수 있었습니다. 이번 업데이트를 통해 디렉토리와 파일을 명확히 구분하여 처리하고, 디렉토리 제거 시 os.RemoveAll을 사용하여 안전성을 확보했습니다. 이는 git-volumecopy 모드에서 디렉토리를 더욱 신뢰성 있게 관리할 수 있도록 합니다.

Highlights

  • 디렉토리 볼륨 처리 개선: unsynccopy 모드에서 디렉토리 볼륨을 처리하는 방식이 파일 중심으로 구현되어 있던 문제를 해결했습니다. 이제 디렉토리와 파일을 구분하여 올바르게 처리합니다.
  • 안전한 디렉토리 제거: 비어있지 않은 디렉토리 제거 실패를 방지하기 위해 os.Remove 대신 os.RemoveAll을 사용하여 디렉토리를 안전하게 제거하도록 removeVolume 함수를 수정했습니다.
  • 콘텐츠 해시 검증 로직 분기: checkRemovable 함수에서 소스/타겟이 디렉토리인지 파일인지 확인하여 verifyDirHash 또는 verifyHash를 호출하도록 로직을 분기했습니다.
  • 테스트 케이스 추가: copy 모드 디렉토리 시나리오에 대한 단위 테스트 및 통합 테스트를 추가하여, 정상 제거, 수정된 디렉토리 스킵, 소스 누락 시 안전 스킵 등의 동작을 검증합니다.

🧠 New Feature in Public Preview: You can now enable Memory to help Gemini Code Assist learn from your team's feedback. This makes future code reviews more consistent and personalized to your project's style. Click here to enable Memory in your admin console.

Changelog
  • go.mod
    • github.com/google/shlex 의존성을 직접 요구사항으로 업데이트했습니다.
  • internal/gitvolume/unsync.go
    • checkRemovable 함수에서 copy 모드 볼륨의 소스 타입(파일 또는 디렉토리)을 확인하여 적절한 해시 검증 함수(verifyHash 또는 verifyDirHash)를 호출하도록 수정했습니다.
    • removeVolume 함수에서 대상 경로가 디렉토리인 경우 os.RemoveAll을 사용하여 재귀적으로 제거하고, 파일인 경우 os.Remove를 사용하도록 로직을 분기했습니다.
  • internal/gitvolume/unsync_test.go
    • TestGitVolume_Unsync_CopyDirectory 테스트를 추가하여 copy 모드에서 디렉토리가 올바르게 동기화되고 제거되는지 확인합니다.
    • TestGitVolume_Unsync_CopyDirectory_Modified 테스트를 추가하여 copy 모드에서 수정된 디렉토리가 unsync 시 보존되는지 확인합니다.
    • TestGitVolume_Unsync_CopyDirectory_MissingSource 테스트를 추가하여 소스 디렉토리가 없는 경우 대상 디렉토리가 안전하게 제거되지 않고 보존되는지 확인합니다.
  • test/integration.sh
    • unsync copy 디렉토리 통합 테스트를 추가하여 디렉토리 복사 및 제거 기능을 검증합니다.
    • 수정된 copy 디렉토리가 unsync 시 보존되는 시나리오에 대한 통합 테스트를 추가했습니다.
Activity
  • PR 작성자 laggu님이 unsync copy 디렉토리의 안전성 개선을 위해 이 PR을 생성했습니다.
  • PR 설명에는 문제점, 영향받는 파일, 재현 방법, 권장 수정 사항 및 변경 사항이 상세히 기술되어 있습니다.
  • 이 PR은 이슈 #025를 해결합니다.
Using Gemini Code Assist

The full guide for Gemini Code Assist can be found on our documentation page, here are some quick tips.

Invoking Gemini

You can request assistance from Gemini at any point by creating a comment using either /gemini <command> or @gemini-code-assist <command>. Below is a summary of the supported commands on the current page.

Feature Command Description
Code Review /gemini review Performs a code review for the current pull request in its current state.
Pull Request Summary /gemini summary Provides a summary of the current pull request in its current state.
Comment @gemini-code-assist Responds in comments when explicitly tagged, both in pull request comments and review comments.
Help /gemini help Displays a list of available commands.

Customization

To customize Gemini Code Assist for GitHub experience, repository maintainers can create a configuration file and/or provide a custom code review style guide (such as PEP-8 for Python) by creating and adding files to a .gemini/ folder in the base of the repository. Detailed instructions can be found here.

Limitations & Feedback

Gemini Code Assist may make mistakes. Please leave feedback on any instances where its feedback is incorrect or counter productive. You can react with 👍 and 👎 on @gemini-code-assist comments. If you're interested in giving your feedback about your experience with Gemini Code Assist for Github and other Google products, sign up here.

You can also get AI-powered code generation, chat, as well as code reviews directly in the IDE at no cost with the Gemini Code Assist IDE Extension.

Footnotes

  1. Review the Privacy Notices, Generative AI Prohibited Use Policy, Terms of Service, and learn how to configure Gemini Code Assist in GitHub here. Gemini can make mistakes, so double check it and use code with caution.

Copy link

@gemini-code-assist gemini-code-assist bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Code Review

이 PR은 unsync 명령의 copy 모드에서 디렉토리 볼륨 처리의 안전성을 크게 개선했습니다. checkRemovable 함수가 이제 파일과 디렉토리를 올바르게 구분하여 해시를 검증하고, removeVolume 함수는 디렉토리 삭제 시 os.RemoveAll을 사용하여 비어있지 않은 디렉토리도 안전하게 제거할 수 있도록 변경되었습니다. 또한, 수정된 디렉토리가 보존되고 소스가 누락된 경우 안전하게 스킵되는 시나리오를 포함한 포괄적인 테스트 케이스가 추가되어 견고성을 높였습니다. 전반적으로 잘 구현된 변경 사항입니다.

@laggu laggu merged commit 57ac723 into develop Feb 18, 2026
6 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant