|
11 | 11 | *as a service. |
12 | 12 | * |
13 | 13 | * IDENTIFICATION |
14 | | - * $PostgreSQL: pgsql/src/port/copydir.c,v 1.27 2010/02/1504:05:06 itagaki Exp $ |
| 14 | + * $PostgreSQL: pgsql/src/port/copydir.c,v 1.28 2010/02/1511:40:49 stark Exp $ |
15 | 15 | * |
16 | 16 | *------------------------------------------------------------------------- |
17 | 17 | */ |
@@ -101,22 +101,36 @@ copydir(char *fromdir, char *todir, bool recurse) |
101 | 101 |
|
102 | 102 | while ((xlde=ReadDir(xldir,fromdir))!=NULL) |
103 | 103 | { |
| 104 | +structstatfst; |
| 105 | + |
104 | 106 | if (strcmp(xlde->d_name,".")==0|| |
105 | 107 | strcmp(xlde->d_name,"..")==0) |
106 | 108 | continue; |
107 | 109 |
|
108 | 110 | snprintf(tofile,MAXPGPATH,"%s/%s",todir,xlde->d_name); |
109 | | -fsync_fname(tofile); |
| 111 | + |
| 112 | +/* We don't need to sync directories here since the recursive |
| 113 | + * copydir will do it before it returns */ |
| 114 | +if (lstat(fromfile,&fst)<0) |
| 115 | +ereport(ERROR, |
| 116 | +(errcode_for_file_access(), |
| 117 | +errmsg("could not stat file \"%s\": %m",fromfile))); |
| 118 | +if (S_ISREG(fst.st_mode)) |
| 119 | +{ |
| 120 | +fsync_fname(tofile); |
| 121 | +} |
110 | 122 | } |
111 | 123 | FreeDir(xldir); |
112 | 124 |
|
| 125 | +#ifdefNOTYET |
113 | 126 | /* It's important to fsync the destination directory itself as |
114 | 127 | * individual file fsyncs don't guarantee that the directory entry |
115 | 128 | * for the file is synced. Recent versions of ext4 have made the |
116 | 129 | * window much wider but it's been true for ext3 and other |
117 | | - *filesyetems in the past |
| 130 | + *filesystems in the past |
118 | 131 | */ |
119 | 132 | fsync_fname(todir); |
| 133 | +#endif |
120 | 134 | } |
121 | 135 |
|
122 | 136 | /* |
|