1. 증분 백업 버그 수정
2. 일반 백업 해쉬 비교 추가
This commit is contained in:
@@ -199,7 +199,7 @@ func RunBackup(ctx context.Context, src, dst string, opts Options) error {
|
|||||||
dstInfo, err := os.Stat(dstPath)
|
dstInfo, err := os.Stat(dstPath)
|
||||||
fileExists := err == nil
|
fileExists := err == nil
|
||||||
|
|
||||||
if fileExists && !opts.Force {
|
if !opts.Force {
|
||||||
if opts.Incremental {
|
if opts.Incremental {
|
||||||
// 증분 백업 모드에서는 메타데이터를 확인
|
// 증분 백업 모드에서는 메타데이터를 확인
|
||||||
srcInfo, err := os.Stat(srcPath)
|
srcInfo, err := os.Stat(srcPath)
|
||||||
@@ -230,30 +230,32 @@ func RunBackup(ctx context.Context, src, dst string, opts Options) error {
|
|||||||
|
|
||||||
meta.Files[relPath] = newValue
|
meta.Files[relPath] = newValue
|
||||||
} else {
|
} else {
|
||||||
// 일반 모드에서는 크기와 수정 시간만 비교
|
if fileExists {
|
||||||
srcInfo, err := os.Stat(srcPath)
|
// 일반 모드에서는 크기와 수정 시간만 비교
|
||||||
if err != nil {
|
srcInfo, err := os.Stat(srcPath)
|
||||||
return fmt.Errorf("원본 파일 정보를 읽을 수 없습니다: %w", err)
|
if err != nil {
|
||||||
}
|
return fmt.Errorf("원본 파일 정보를 읽을 수 없습니다: %w", err)
|
||||||
|
}
|
||||||
|
|
||||||
switch opts.CompareMode {
|
switch opts.CompareMode {
|
||||||
case CompareTime:
|
case CompareTime:
|
||||||
if srcInfo.Size() == dstInfo.Size() && srcInfo.ModTime().Equal(dstInfo.ModTime()) {
|
if srcInfo.Size() == dstInfo.Size() && srcInfo.ModTime().Equal(dstInfo.ModTime()) {
|
||||||
opts.Logger.Printf("건너뜀 (시간 동일): %s\n", relPath)
|
opts.Logger.Printf("건너뜀 (시간 동일): %s\n", relPath)
|
||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
case CompareHash:
|
case CompareHash:
|
||||||
srcHash, err := calculateFileHash(srcPath)
|
srcHash, err := calculateFileHash(srcPath)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return fmt.Errorf("원본 파일 해시를 계산할 수 없습니다: %w", err)
|
return fmt.Errorf("원본 파일 해시를 계산할 수 없습니다: %w", err)
|
||||||
}
|
}
|
||||||
dstHash, err := calculateFileHash(dstPath)
|
dstHash, err := calculateFileHash(dstPath)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return fmt.Errorf("대상 파일 해시를 계산할 수 없습니다: %w", err)
|
return fmt.Errorf("대상 파일 해시를 계산할 수 없습니다: %w", err)
|
||||||
}
|
}
|
||||||
if srcHash == dstHash {
|
if srcHash == dstHash {
|
||||||
opts.Logger.Printf("건너뜀 (해시 동일): %s\n", relPath)
|
opts.Logger.Printf("건너뜀 (해시 동일): %s\n", relPath)
|
||||||
continue
|
continue
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -263,7 +265,6 @@ func RunBackup(ctx context.Context, src, dst string, opts Options) error {
|
|||||||
if err := copyFile(srcPath, dstPath); err != nil {
|
if err := copyFile(srcPath, dstPath); err != nil {
|
||||||
return fmt.Errorf("파일을 복사할 수 없습니다: %w", err)
|
return fmt.Errorf("파일을 복사할 수 없습니다: %w", err)
|
||||||
}
|
}
|
||||||
|
|
||||||
opts.Logger.Printf("복사됨: %s\n", relPath)
|
opts.Logger.Printf("복사됨: %s\n", relPath)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user