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