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

Commit9738beb

Browse files
committed
Fix multiple copy and paste-o's. No wonder this code didn't work.
1 parentb21121c commit9738beb

File tree

1 file changed

+18
-15
lines changed

1 file changed

+18
-15
lines changed

‎src/port/copydir.c

Lines changed: 18 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111
*as a service.
1212
*
1313
* IDENTIFICATION
14-
* $PostgreSQL: pgsql/src/port/copydir.c,v 1.29 2010/02/2200:11:05 stark Exp $
14+
* $PostgreSQL: pgsql/src/port/copydir.c,v 1.30 2010/02/2202:50:10 tgl Exp $
1515
*
1616
*-------------------------------------------------------------------------
1717
*/
@@ -90,18 +90,18 @@ copydir(char *fromdir, char *todir, bool recurse)
9090
elseif (S_ISREG(fst.st_mode))
9191
copy_file(fromfile,tofile);
9292
}
93-
Free(xldir);
93+
FreeDir(xldir);
9494

9595
/*
96-
* Be paranoid here and fsync all files to ensurewe catch problems.
96+
* Be paranoid here and fsync all files to ensurethe copy is really done.
9797
*/
98-
AllocateDir(fromdir);
98+
xldir=AllocateDir(todir);
9999
if (xldir==NULL)
100100
ereport(ERROR,
101101
(errcode_for_file_access(),
102-
errmsg("could not open directory \"%s\": %m",fromdir)));
102+
errmsg("could not open directory \"%s\": %m",todir)));
103103

104-
while ((xlde=ReadDir(xldir,fromdir))!=NULL)
104+
while ((xlde=ReadDir(xldir,todir))!=NULL)
105105
{
106106
structstatfst;
107107

@@ -111,25 +111,29 @@ copydir(char *fromdir, char *todir, bool recurse)
111111

112112
snprintf(tofile,MAXPGPATH,"%s/%s",todir,xlde->d_name);
113113

114-
/* We don't need to sync directories here since the recursive
115-
* copydir will do it before it returns */
116-
if (lstat(fromfile,&fst)<0)
114+
/*
115+
* We don't need to sync subdirectories here since the recursive
116+
* copydir will do it before it returns
117+
*/
118+
if (lstat(tofile,&fst)<0)
117119
ereport(ERROR,
118120
(errcode_for_file_access(),
119-
errmsg("could not stat file \"%s\": %m",fromfile)));
121+
errmsg("could not stat file \"%s\": %m",tofile)));
122+
120123
if (S_ISREG(fst.st_mode))
121-
{
122124
fsync_fname(tofile);
123-
}
124125
}
125126
FreeDir(xldir);
126127

127128
#ifdefNOTYET
128-
/* It's important to fsync the destination directory itself as
129+
/*
130+
* It's important to fsync the destination directory itself as
129131
* individual file fsyncs don't guarantee that the directory entry
130132
* for the file is synced. Recent versions of ext4 have made the
131133
* window much wider but it's been true for ext3 and other
132-
* filesystems in the past
134+
* filesystems in the past.
135+
*
136+
* However we can't do this just yet, it has portability issues.
133137
*/
134138
fsync_fname(todir);
135139
#endif
@@ -210,7 +214,6 @@ copy_file(char *fromfile, char *tofile)
210214
}
211215

212216

213-
214217
/*
215218
* fsync a file
216219
*/

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp