로그 기능 수정
This commit is contained in:
@@ -25,6 +25,7 @@ const (
|
||||
|
||||
type Progress struct {
|
||||
CurrentFile string
|
||||
Status string
|
||||
ProcessedFiles int
|
||||
TotalFiles int
|
||||
}
|
||||
@@ -180,13 +181,6 @@ func RunBackup(ctx context.Context, src, dst string, opts Options) error {
|
||||
default:
|
||||
}
|
||||
|
||||
// 진행 상황 업데이트
|
||||
progress.CurrentFile = srcPath
|
||||
progress.ProcessedFiles = i + 1
|
||||
if opts.Progress != nil {
|
||||
opts.Progress(progress)
|
||||
}
|
||||
|
||||
// 상대 경로 계산
|
||||
relPath, err := filepath.Rel(src, srcPath)
|
||||
if err != nil {
|
||||
@@ -199,6 +193,10 @@ func RunBackup(ctx context.Context, src, dst string, opts Options) error {
|
||||
dstInfo, err := os.Stat(dstPath)
|
||||
fileExists := err == nil
|
||||
|
||||
// 진행 상황 업데이트
|
||||
progress.CurrentFile = srcPath
|
||||
progress.ProcessedFiles = i + 1
|
||||
|
||||
if !opts.Force {
|
||||
if opts.Incremental {
|
||||
// 증분 백업 모드에서는 메타데이터를 확인
|
||||
@@ -214,7 +212,8 @@ func RunBackup(ctx context.Context, src, dst string, opts Options) error {
|
||||
case CompareTime:
|
||||
newValue = srcInfo.ModTime().String()
|
||||
if exists && oldValue == newValue {
|
||||
opts.Logger.Printf("건너뜀 (시간 동일): %s\n", relPath)
|
||||
progress.Status = "건너뜀 (시간 동일)"
|
||||
opts.Progress(progress)
|
||||
continue
|
||||
}
|
||||
case CompareHash:
|
||||
@@ -223,7 +222,8 @@ func RunBackup(ctx context.Context, src, dst string, opts Options) error {
|
||||
return fmt.Errorf("파일 해시를 계산할 수 없습니다: %w", err)
|
||||
}
|
||||
if exists && oldValue == newValue {
|
||||
opts.Logger.Printf("건너뜀 (해시 동일): %s\n", relPath)
|
||||
progress.Status = "건너뜀 (해시 동일)"
|
||||
opts.Progress(progress)
|
||||
continue
|
||||
}
|
||||
}
|
||||
@@ -240,7 +240,8 @@ func RunBackup(ctx context.Context, src, dst string, opts Options) error {
|
||||
switch opts.CompareMode {
|
||||
case CompareTime:
|
||||
if srcInfo.Size() == dstInfo.Size() && srcInfo.ModTime().Equal(dstInfo.ModTime()) {
|
||||
opts.Logger.Printf("건너뜀 (시간 동일): %s\n", relPath)
|
||||
progress.Status = "건너뜀 (시간 동일)"
|
||||
opts.Progress(progress)
|
||||
continue
|
||||
}
|
||||
case CompareHash:
|
||||
@@ -253,7 +254,8 @@ func RunBackup(ctx context.Context, src, dst string, opts Options) error {
|
||||
return fmt.Errorf("대상 파일 해시를 계산할 수 없습니다: %w", err)
|
||||
}
|
||||
if srcHash == dstHash {
|
||||
opts.Logger.Printf("건너뜀 (해시 동일): %s\n", relPath)
|
||||
progress.Status = "건너뜀 (해시 동일)"
|
||||
opts.Progress(progress)
|
||||
continue
|
||||
}
|
||||
}
|
||||
@@ -265,7 +267,11 @@ func RunBackup(ctx context.Context, src, dst string, opts Options) error {
|
||||
if err := copyFile(srcPath, dstPath); err != nil {
|
||||
return fmt.Errorf("파일을 복사할 수 없습니다: %w", err)
|
||||
}
|
||||
opts.Logger.Printf("복사됨: %s\n", relPath)
|
||||
|
||||
progress.Status = "복사됨"
|
||||
if opts.Progress != nil {
|
||||
opts.Progress(progress)
|
||||
}
|
||||
}
|
||||
|
||||
// 증분 백업 메타데이터 저장
|
||||
|
||||
Reference in New Issue
Block a user