Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit b37b222

Browse files
committed
fix ssu_rsync compare bug
1 parent 5c8a6cd commit b37b222

File tree

1 file changed

+10
-6
lines changed

1 file changed

+10
-6
lines changed

‎ssu_rsync.c‎

Lines changed: 10 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ int in_fd; // 표준 입력
2222
int out_fd; // 표준 출력
2323
int err_fd; // 표준 에러
2424

25-
file_node change_list[BUFFER_SIZE]; // 변경 목록
25+
file_node change_list[MAX_BUFFER_SIZE]; // 변경 목록
2626
char **saved_argv;
2727
int saved_argc;
2828
bool src_is_dir = false;
@@ -394,9 +394,9 @@ bool compare_file(file_node *src_file, file_node *dst_file) // 파일 정보 비
394394
while (now != NULL) {
395395

396396
#ifdef DEBUG
397-
printf("compare_file(): src_file->name = %s, dst_file->name = %s\n", src_file->name + strlen(pwd) +1, now->name + strlen(dst_path) + 1);
397+
printf("compare_file(): src_file->name = %s, dst_file->name = %s\n", src_file->name + strlen(src_path) -strlen(get_file_name(src_path)), now->name + strlen(dst_path) + 1);
398398
#endif
399-
if (!strcmp(src_file->name + strlen(pwd) +1, now->name + strlen(dst_path) + 1)) { // 파일 이름이 같은 경우
399+
if (!strcmp(src_file->name + strlen(src_path) -strlen(get_file_name(src_path)), now->name + strlen(dst_path) + 1)) { // 파일 이름이 같은 경우
400400

401401
#ifdef DEBUG
402402
printf("compare_file(): file found\n");
@@ -482,7 +482,7 @@ int write_change_list(file_node *head, int idx, int status, bool is_first) //
482482
break;
483483
}
484484

485-
if(option_r || is_first)
485+
if(option_r || is_first)// R옵션이 존재하거나 첫번째 레벨일 경우
486486
if (now->child != NULL)
487487
idx = write_change_list(now->child, idx, status, false);
488488

@@ -505,7 +505,8 @@ void renewal(int count) // 파일 동기화
505505
struct utimbuf attr;
506506
size_t length;
507507

508-
sprintf(path, "%.*s/%s", (int)strlen(dst_path), dst_path, get_file_name(src_path));
508+
// 타겟 디렉토리가 존재하지 않을경우 동기화 디렉토리에 생성
509+
sprintf(path, "%.*s/%s", (int)strlen(dst_path), dst_path, get_file_name(src_path));
509510
if (src_is_dir && access(path, F_OK) < 0) {
510511
lstat(src_path, &statbuf);
511512
mkdir(path, statbuf.st_mode);
@@ -529,7 +530,10 @@ void renewal(int count) // 파일 동기화
529530
memset(path, 0, MAX_BUFFER_SIZE);
530531

531532
lstat(change_list[i].name, &statbuf);
532-
sprintf(path, "%.*s/%s", (int)strlen(dst_path), dst_path, change_list[i].name + strlen(pwd) + 1); // 동기화 파일 경로 생성
533+
sprintf(path, "%.*s/%s", (int)strlen(dst_path), dst_path, change_list[i].name + strlen(src_path) - strlen(get_file_name(src_path))); // 동기화 파일 경로 생성
534+
#ifdef DEBUG
535+
printf("renewal: path = %s\n", path);
536+
#endif
533537

534538
if (S_ISDIR(statbuf.st_mode))
535539
mkdir(path, 0755);

0 commit comments

Comments
(0)

AltStyle によって変換されたページ (->オリジナル) /