Movatterモバイル変換


[0]ホーム

URL:


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

Commit967a17f

Browse files
committed
Refactor basebackup.c's _tarWriteDir() function.
Sometimes, we replace a symbolic link that we find in the datadirectory with an actual directory within the tarfile that wecreate. _tarWriteDir was responsible both for making thissubstitution and also for writing the tar header for theresulting directory into the tar file. Make it do only the firstof those things, and rename to convert_link_to_directory.Substantially larger refactoring of this source file is planned,but this little bit seemed to make sense to commitindependently.Discussion:http://postgr.es/m/CA+Tgmobz6tuv5tr-WxURe5JA1vVcGz85k4kkvoWxcyHvDpEqFA@mail.gmail.com
1 parentd9ddc50 commit967a17f

File tree

1 file changed

+14
-12
lines changed

1 file changed

+14
-12
lines changed

‎src/backend/replication/basebackup.c

Lines changed: 14 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -71,8 +71,7 @@ static void sendFileWithContent(const char *filename, const char *content,
7171
backup_manifest_info*manifest);
7272
staticint64_tarWriteHeader(constchar*filename,constchar*linktarget,
7373
structstat*statbuf,boolsizeonly);
74-
staticint64_tarWriteDir(constchar*pathbuf,intbasepathlen,structstat*statbuf,
75-
boolsizeonly);
74+
staticvoidconvert_link_to_directory(constchar*pathbuf,structstat*statbuf);
7675
staticvoidsend_int8_string(StringInfoData*buf,int64intval);
7776
staticvoidSendBackupHeader(List*tablespaces);
7877
staticvoidperform_base_backup(basebackup_options*opt);
@@ -1381,7 +1380,9 @@ sendDir(const char *path, int basepathlen, bool sizeonly, List *tablespaces,
13811380
if (strcmp(de->d_name,excludeDirContents[excludeIdx])==0)
13821381
{
13831382
elog(DEBUG1,"contents of directory \"%s\" excluded from backup",de->d_name);
1384-
size+=_tarWriteDir(pathbuf,basepathlen,&statbuf,sizeonly);
1383+
convert_link_to_directory(pathbuf,&statbuf);
1384+
size+=_tarWriteHeader(pathbuf+basepathlen+1,NULL,&statbuf,
1385+
sizeonly);
13851386
excludeFound= true;
13861387
break;
13871388
}
@@ -1397,7 +1398,9 @@ sendDir(const char *path, int basepathlen, bool sizeonly, List *tablespaces,
13971398
if (statrelpath!=NULL&&strcmp(pathbuf,statrelpath)==0)
13981399
{
13991400
elog(DEBUG1,"contents of directory \"%s\" excluded from backup",statrelpath);
1400-
size+=_tarWriteDir(pathbuf,basepathlen,&statbuf,sizeonly);
1401+
convert_link_to_directory(pathbuf,&statbuf);
1402+
size+=_tarWriteHeader(pathbuf+basepathlen+1,NULL,&statbuf,
1403+
sizeonly);
14011404
continue;
14021405
}
14031406

@@ -1409,7 +1412,9 @@ sendDir(const char *path, int basepathlen, bool sizeonly, List *tablespaces,
14091412
if (strcmp(pathbuf,"./pg_wal")==0)
14101413
{
14111414
/* If pg_wal is a symlink, write it as a directory anyway */
1412-
size+=_tarWriteDir(pathbuf,basepathlen,&statbuf,sizeonly);
1415+
convert_link_to_directory(pathbuf,&statbuf);
1416+
size+=_tarWriteHeader(pathbuf+basepathlen+1,NULL,&statbuf,
1417+
sizeonly);
14131418

14141419
/*
14151420
* Also send archive_status directory (by hackishly reusing
@@ -1883,12 +1888,11 @@ _tarWriteHeader(const char *filename, const char *linktarget,
18831888
}
18841889

18851890
/*
1886-
*Write tar header for a directory.If the entry in statbuf is a link then
1887-
*writeitas a directory anyway.
1891+
* If the entry in statbuf is a link, then adjust statbuf to make it look like a
1892+
*directory, so thatitwill be written that way.
18881893
*/
1889-
staticint64
1890-
_tarWriteDir(constchar*pathbuf,intbasepathlen,structstat*statbuf,
1891-
boolsizeonly)
1894+
staticvoid
1895+
convert_link_to_directory(constchar*pathbuf,structstat*statbuf)
18921896
{
18931897
/* If symlink, write it as a directory anyway */
18941898
#ifndefWIN32
@@ -1897,8 +1901,6 @@ _tarWriteDir(const char *pathbuf, int basepathlen, struct stat *statbuf,
18971901
if (pgwin32_is_junction(pathbuf))
18981902
#endif
18991903
statbuf->st_mode=S_IFDIR |pg_dir_create_mode;
1900-
1901-
return_tarWriteHeader(pathbuf+basepathlen+1,NULL,statbuf,sizeonly);
19021904
}
19031905

19041906
/*

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp