Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
P
postgres-lambda-diff
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Container registry
Model registry
Operate
Environments
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Jakob Huber
postgres-lambda-diff
Commits
9738beb3
Commit
9738beb3
authored
15 years ago
by
Tom Lane
Browse files
Options
Downloads
Patches
Plain Diff
Fix multiple copy and paste-o's. No wonder this code didn't work.
parent
b21121cd
No related branches found
No related tags found
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
src/port/copydir.c
+18
-15
18 additions, 15 deletions
src/port/copydir.c
with
18 additions
and
15 deletions
src/port/copydir.c
+
18
−
15
View file @
9738beb3
...
@@ -11,7 +11,7 @@
...
@@ -11,7 +11,7 @@
* as a service.
* as a service.
*
*
* IDENTIFICATION
* IDENTIFICATION
* $PostgreSQL: pgsql/src/port/copydir.c,v 1.
29
2010/02/22 0
0:11:05 stark
Exp $
* $PostgreSQL: pgsql/src/port/copydir.c,v 1.
30
2010/02/22 0
2:50:10 tgl
Exp $
*
*
*-------------------------------------------------------------------------
*-------------------------------------------------------------------------
*/
*/
...
@@ -90,18 +90,18 @@ copydir(char *fromdir, char *todir, bool recurse)
...
@@ -90,18 +90,18 @@ copydir(char *fromdir, char *todir, bool recurse)
else
if
(
S_ISREG
(
fst
.
st_mode
))
else
if
(
S_ISREG
(
fst
.
st_mode
))
copy_file
(
fromfile
,
tofile
);
copy_file
(
fromfile
,
tofile
);
}
}
Free
(
xldir
);
Free
Dir
(
xldir
);
/*
/*
* Be paranoid here and fsync all files to ensure
w
e c
atch problems
.
* Be paranoid here and fsync all files to ensure
th
e c
opy is really done
.
*/
*/
AllocateDir
(
from
dir
);
xldir
=
AllocateDir
(
to
dir
);
if
(
xldir
==
NULL
)
if
(
xldir
==
NULL
)
ereport
(
ERROR
,
ereport
(
ERROR
,
(
errcode_for_file_access
(),
(
errcode_for_file_access
(),
errmsg
(
"could not open directory
\"
%s
\"
: %m"
,
from
dir
)));
errmsg
(
"could not open directory
\"
%s
\"
: %m"
,
to
dir
)));
while
((
xlde
=
ReadDir
(
xldir
,
from
dir
))
!=
NULL
)
while
((
xlde
=
ReadDir
(
xldir
,
to
dir
))
!=
NULL
)
{
{
struct
stat
fst
;
struct
stat
fst
;
...
@@ -111,25 +111,29 @@ copydir(char *fromdir, char *todir, bool recurse)
...
@@ -111,25 +111,29 @@ copydir(char *fromdir, char *todir, bool recurse)
snprintf
(
tofile
,
MAXPGPATH
,
"%s/%s"
,
todir
,
xlde
->
d_name
);
snprintf
(
tofile
,
MAXPGPATH
,
"%s/%s"
,
todir
,
xlde
->
d_name
);
/* We don't need to sync directories here since the recursive
/*
* copydir will do it before it returns */
* We don't need to sync subdirectories here since the recursive
if
(
lstat
(
fromfile
,
&
fst
)
<
0
)
* copydir will do it before it returns
*/
if
(
lstat
(
tofile
,
&
fst
)
<
0
)
ereport
(
ERROR
,
ereport
(
ERROR
,
(
errcode_for_file_access
(),
(
errcode_for_file_access
(),
errmsg
(
"could not stat file
\"
%s
\"
: %m"
,
fromfile
)));
errmsg
(
"could not stat file
\"
%s
\"
: %m"
,
tofile
)));
if
(
S_ISREG
(
fst
.
st_mode
))
if
(
S_ISREG
(
fst
.
st_mode
))
{
fsync_fname
(
tofile
);
fsync_fname
(
tofile
);
}
}
}
FreeDir
(
xldir
);
FreeDir
(
xldir
);
#ifdef NOTYET
#ifdef NOTYET
/* It's important to fsync the destination directory itself as
/*
* It's important to fsync the destination directory itself as
* individual file fsyncs don't guarantee that the directory entry
* individual file fsyncs don't guarantee that the directory entry
* for the file is synced. Recent versions of ext4 have made the
* for the file is synced. Recent versions of ext4 have made the
* window much wider but it's been true for ext3 and other
* window much wider but it's been true for ext3 and other
* filesystems in the past
* filesystems in the past.
*
* However we can't do this just yet, it has portability issues.
*/
*/
fsync_fname
(
todir
);
fsync_fname
(
todir
);
#endif
#endif
...
@@ -210,7 +214,6 @@ copy_file(char *fromfile, char *tofile)
...
@@ -210,7 +214,6 @@ copy_file(char *fromfile, char *tofile)
}
}
/*
/*
* fsync a file
* fsync a file
*/
*/
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment