mirror of
https://github.com/postgrespro/pg_probackup.git
synced 2026-06-21 01:34:15 +02:00
[PBCKP-395] use pioOpenRewrite in create_empty_file
This commit is contained in:
+20
-14
@@ -1206,27 +1206,33 @@ cleanup:
|
||||
* Create empty file, used for partial restore
|
||||
*/
|
||||
bool
|
||||
create_empty_file(fio_location from_location, const char *to_root,
|
||||
fio_location to_location, pgFile *file)
|
||||
create_empty_file(const char *to_root, fio_location to_location, pgFile *file)
|
||||
{
|
||||
FOBJ_FUNC_ARP();
|
||||
char to_path[MAXPGPATH];
|
||||
FILE *out;
|
||||
pioDrive_i drive = pioDriveForLocation(to_location);
|
||||
pioWriteCloser_i fl;
|
||||
err_i err;
|
||||
|
||||
/* open file for write */
|
||||
join_path_components(to_path, to_root, file->rel_path);
|
||||
out = fio_fopen(to_location, to_path, PG_BINARY_W);
|
||||
/*
|
||||
* TODO: possibly it is better to use pioWriteFile, but it doesn't have
|
||||
* permissions parameter, and I don't want to introduce is just for one
|
||||
* use case
|
||||
*/
|
||||
fl = $i(pioOpenRewrite, drive,
|
||||
.permissions = file->mode,
|
||||
.use_temp = false,
|
||||
.err = &err);
|
||||
if ($haserr(err))
|
||||
ft_logerr(FT_ERROR, $errmsg(err), "Creating empty file");
|
||||
|
||||
if (out == NULL)
|
||||
elog(ERROR, "Cannot open destination file \"%s\": %s",
|
||||
to_path, strerror(errno));
|
||||
err = $i(pioWriteFinish, fl);
|
||||
err = fobj_err_combine(err, $i(pioClose, fl, .sync=false));
|
||||
|
||||
/* update file permission */
|
||||
if (fio_chmod(to_location, to_path, file->mode) == -1)
|
||||
elog(ERROR, "Cannot change mode of \"%s\": %s", to_path,
|
||||
strerror(errno));
|
||||
|
||||
if (fio_fclose(out))
|
||||
elog(ERROR, "Cannot close \"%s\": %s", to_path, strerror(errno));
|
||||
if ($haserr(err))
|
||||
ft_logerr(FT_ERROR, $errmsg(err), "Closing empty file");
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
+1
-2
@@ -1054,8 +1054,7 @@ extern size_t restore_non_data_file(parray *parent_chain, pgBackup *dest_backup,
|
||||
bool already_exists);
|
||||
extern void restore_non_data_file_internal(FILE *in, FILE *out, pgFile *file,
|
||||
const char *from_fullpath, const char *to_fullpath);
|
||||
extern bool create_empty_file(fio_location from_location, const char *to_root,
|
||||
fio_location to_location, pgFile *file);
|
||||
extern bool create_empty_file(const char *to_root, fio_location to_location, pgFile *file);
|
||||
|
||||
extern PageState *get_checksum_map(const char *fullpath, uint32 checksum_version,
|
||||
int n_blocks, XLogRecPtr dest_stop_lsn, BlockNumber segmentno);
|
||||
|
||||
+1
-2
@@ -1158,8 +1158,7 @@ restore_files(void *arg)
|
||||
* We cannot simply skip the file, because it may lead to
|
||||
* failure during WAL redo; hence, create empty file.
|
||||
*/
|
||||
create_empty_file(FIO_BACKUP_HOST,
|
||||
arguments->to_root, FIO_DB_HOST, dest_file);
|
||||
create_empty_file(arguments->to_root, FIO_DB_HOST, dest_file);
|
||||
|
||||
elog(LOG, "Skip file due to partial restore: \"%s\"",
|
||||
dest_file->rel_path);
|
||||
|
||||
Reference in New Issue
Block a user