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

Commit6ec34f8

Browse files
committed
fix file delete on Windows
1 parent852c993 commit6ec34f8

File tree

7 files changed

+44
-39
lines changed

7 files changed

+44
-39
lines changed

‎src/delete.c‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -768,7 +768,7 @@ delete_backup_files(pgBackup *backup)
768768
elog(INFO,"Progress: (%zd/%zd). Delete file \"%s\"",
769769
i+1,num_files,full_path);
770770

771-
pgFileDelete(file,full_path);
771+
pgFileDelete(file->mode,full_path);
772772
}
773773

774774
parray_walk(files,pgFileFree);

‎src/dir.c‎

Lines changed: 2 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -225,9 +225,9 @@ pgFileInit(const char *rel_path)
225225
* If the pgFile points directory, the directory must be empty.
226226
*/
227227
void
228-
pgFileDelete(pgFile*file,constchar*full_path)
228+
pgFileDelete(mode_tmode,constchar*full_path)
229229
{
230-
if (S_ISDIR(file->mode))
230+
if (S_ISDIR(mode))
231231
{
232232
if (rmdir(full_path)==-1)
233233
{
@@ -252,38 +252,6 @@ pgFileDelete(pgFile *file, const char *full_path)
252252
}
253253
}
254254

255-
/*
256-
* Delete file pointed by the pgFile.
257-
* If the pgFile points directory, the directory must be empty.
258-
*/
259-
void
260-
fio_pgFileDelete(pgFile*file,constchar*full_path)
261-
{
262-
if (S_ISDIR(file->mode))
263-
{
264-
if (fio_unlink(full_path,FIO_DB_HOST)==-1)
265-
{
266-
if (errno==ENOENT)
267-
return;
268-
elseif (errno==ENOTDIR)/* could be symbolic link */
269-
gotodelete_file;
270-
271-
elog(ERROR,"Cannot remove directory \"%s\": %s",
272-
full_path,strerror(errno));
273-
}
274-
return;
275-
}
276-
277-
delete_file:
278-
if (fio_unlink(full_path,FIO_DB_HOST)==-1)
279-
{
280-
if (errno==ENOENT)
281-
return;
282-
elog(ERROR,"Cannot remove file \"%s\": %s",full_path,
283-
strerror(errno));
284-
}
285-
}
286-
287255
/*
288256
* Read the local file to compute its CRC.
289257
* We cannot make decision about file decompression because

‎src/merge.c‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -806,7 +806,7 @@ merge_chain(parray *parent_chain, pgBackup *full_backup, pgBackup *dest_backup)
806806
/* We need full path, file object has relative path */
807807
join_path_components(full_file_path,full_database_dir,full_file->rel_path);
808808

809-
pgFileDelete(full_file,full_file_path);
809+
pgFileDelete(full_file->mode,full_file_path);
810810
elog(VERBOSE,"Deleted \"%s\"",full_file_path);
811811
}
812812
}
@@ -1141,7 +1141,7 @@ remove_dir_with_files(const char *path)
11411141

11421142
join_path_components(full_path,path,file->rel_path);
11431143

1144-
pgFileDelete(file,full_path);
1144+
pgFileDelete(file->mode,full_path);
11451145
elog(VERBOSE,"Deleted \"%s\"",full_path);
11461146
}
11471147

‎src/pg_probackup.h‎

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -970,7 +970,7 @@ extern pgFile *pgFileNew(const char *path, const char *rel_path,
970970
boolfollow_symlink,intexternal_dir_num,
971971
fio_locationlocation);
972972
externpgFile*pgFileInit(constchar*rel_path);
973-
externvoidpgFileDelete(pgFile*file,constchar*full_path);
973+
externvoidpgFileDelete(mode_tmode,constchar*full_path);
974974
externvoidfio_pgFileDelete(pgFile*file,constchar*full_path);
975975

976976
externvoidpgFileFree(void*file);
@@ -1123,6 +1123,7 @@ extern int send_pages(ConnectionArgs* conn_arg, const char *to_fullpath, const c
11231123
BackupModebackup_mode,intptrack_version_num,constchar*ptrack_schema);
11241124

11251125
/* FIO */
1126+
externvoidfio_delete(mode_tmode,constchar*fullpath,fio_locationlocation);
11261127
externintfio_send_pages(constchar*to_fullpath,constchar*from_fullpath,pgFile*file,XLogRecPtrhorizonLsn,
11271128
intcalg,intclevel,uint32checksum_version,datapagemap_t*pagemap,
11281129
BlockNumber*err_blknum,char**errormsg,BackupPageHeader2**headers);

‎src/restore.c‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -836,7 +836,7 @@ restore_chain(pgBackup *dest_backup, parray *parent_chain,
836836
join_path_components(fullpath,pgdata_path,file->rel_path);
837837

838838
//fio_pgFileDelete(file, full_file_path);
839-
pgFileDelete(file,fullpath);
839+
fio_delete(file->mode,fullpath,FIO_DB_HOST);
840840
elog(VERBOSE,"Deleted file \"%s\"",fullpath);
841841

842842
/* shrink pgdata list */

‎src/utils/file.c‎

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2492,6 +2492,37 @@ static void fio_check_postmaster_impl(int out, char *buf)
24922492
IO_CHECK(fio_write_all(out,&hdr,sizeof(hdr)),sizeof(hdr));
24932493
}
24942494

2495+
/*
2496+
* Delete file pointed by the pgFile.
2497+
* If the pgFile points directory, the directory must be empty.
2498+
*/
2499+
void
2500+
fio_delete(mode_tmode,constchar*fullpath,fio_locationlocation)
2501+
{
2502+
if (fio_is_remote(location))
2503+
{
2504+
fio_headerhdr;
2505+
2506+
hdr.cop=FIO_DELETE;
2507+
hdr.size=strlen(fullpath)+1;
2508+
hdr.arg=mode;
2509+
2510+
IO_CHECK(fio_write_all(fio_stdout,&hdr,sizeof(hdr)),sizeof(hdr));
2511+
IO_CHECK(fio_write_all(fio_stdout,fullpath,hdr.size),hdr.size);
2512+
2513+
}
2514+
else
2515+
pgFileDelete(mode,fullpath);
2516+
}
2517+
2518+
staticvoid
2519+
fio_delete_impl(mode_tmode,char*buf)
2520+
{
2521+
char*fullpath= (char*)buf;
2522+
2523+
pgFileDelete(mode,fullpath);
2524+
}
2525+
24952526
/* Execute commands at remote host */
24962527
voidfio_communicate(intin,intout)
24972528
{
@@ -2675,6 +2706,10 @@ void fio_communicate(int in, int out)
26752706
/* calculate crc32 for a file */
26762707
fio_check_postmaster_impl(out,buf);
26772708
break;
2709+
caseFIO_DELETE:
2710+
/* delete file */
2711+
fio_delete_impl(hdr.arg,buf);
2712+
break;
26782713
caseFIO_DISCONNECT:
26792714
hdr.cop=FIO_DISCONNECTED;
26802715
IO_CHECK(fio_write_all(out,&hdr,sizeof(hdr)),sizeof(hdr));

‎src/utils/file.h‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@ typedef enum
2323
FIO_CHMOD,
2424
FIO_SEEK,
2525
FIO_TRUNCATE,
26+
FIO_DELETE,
2627
FIO_PREAD,
2728
FIO_READ,
2829
FIO_LOAD,

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp