백업 내용 없을 경우 폴더 삭제
This commit is contained in:
@@ -253,8 +253,4 @@ func main() {
|
||||
}
|
||||
os.Exit(1)
|
||||
}
|
||||
|
||||
if opts.Verbose {
|
||||
fmt.Println("\n백업이 성공적으로 완료되었습니다")
|
||||
}
|
||||
}
|
||||
|
||||
@@ -106,6 +106,7 @@ func calculateFileHash(path string) (string, error) {
|
||||
}
|
||||
|
||||
func RunBackup(ctx context.Context, src, dst string, opts Options) error {
|
||||
|
||||
if opts.dirCache == nil {
|
||||
opts.dirCache = path.NewDirCache()
|
||||
}
|
||||
@@ -282,5 +283,19 @@ func RunBackup(ctx context.Context, src, dst string, opts Options) error {
|
||||
}
|
||||
}
|
||||
|
||||
entries, err := os.ReadDir(dst)
|
||||
if err != nil {
|
||||
return fmt.Errorf("디렉토리 읽기 실패: %w", err)
|
||||
}
|
||||
|
||||
if len(entries) == 0 {
|
||||
err := os.Remove(dst)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
opts.Logger.Printf("백업된 내역이 없습니다.")
|
||||
} else {
|
||||
fmt.Println("\n백업이 성공적으로 완료되었습니다")
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user