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

Commit336ebee

Browse files
committed
copydir() is supposed to return on failure, not elog(ERROR). Reduce
ERROR to WARNING so we keep control.
1 parentd16b877 commit336ebee

File tree

1 file changed

+18
-11
lines changed

1 file changed

+18
-11
lines changed

‎src/port/copydir.c

Lines changed: 18 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,9 @@
11
/*
22
*While "xcopy /e /i /q" works fine for copying directories, on Windows XP
3-
*it requiresan Window handle which prevents it from working when invoked
3+
*it requiresa Window handle which prevents it from working when invoked
44
*as a service.
5+
*
6+
* $Header: /cvsroot/pgsql/src/port/Attic/copydir.c,v 1.5 2003/09/10 20:12:01 tgl Exp $
57
*/
68

79
#include"postgres.h"
@@ -12,6 +14,14 @@
1214
#include<dirent.h>
1315

1416

17+
/*
18+
* copydir: copy a directory (we only need to go one level deep)
19+
*
20+
* Return 0 on success, nonzero on failure.
21+
*
22+
* NB: do not elog(ERROR) on failure. Return to caller so it can try to
23+
* clean up.
24+
*/
1525
int
1626
copydir(char*fromdir,char*todir)
1727
{
@@ -22,18 +32,18 @@ copydir(char *fromdir, char *todir)
2232

2333
if (mkdir(todir)!=0)
2434
{
25-
ereport(ERROR,
35+
ereport(WARNING,
2636
(errcode_for_file_access(),
2737
errmsg("could not create directory \"%s\": %m",todir)));
28-
return1;
38+
return-1;
2939
}
3040
xldir=opendir(fromdir);
3141
if (xldir==NULL)
3242
{
33-
ereport(ERROR,
43+
ereport(WARNING,
3444
(errcode_for_file_access(),
3545
errmsg("could not open directory \"%s\": %m",fromdir)));
36-
return1;
46+
return-1;
3747
}
3848

3949
while ((xlde=readdir(xldir))!=NULL)
@@ -42,14 +52,11 @@ copydir(char *fromdir, char *todir)
4252
snprintf(tofl,MAXPGPATH,"%s/%s",todir,xlde->d_name);
4353
if (CopyFile(fromfl,tofl, TRUE)<0)
4454
{
45-
intsave_errno=errno;
46-
47-
closedir(xldir);
48-
errno=save_errno;
49-
ereport(ERROR,
55+
ereport(WARNING,
5056
(errcode_for_file_access(),
5157
errmsg("could not copy file \"%s\": %m",fromfl)));
52-
return1;
58+
closedir(xldir);
59+
return-1;
5360
}
5461
}
5562

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp