nonlib: Use tmp file when generating snapshot.
This commit is contained in:
parent
14099b7cfc
commit
7d5a0e13f6
|
@ -568,13 +568,21 @@ Loggable::snapshot ( const char *name )
|
||||||
{
|
{
|
||||||
FILE *fp;
|
FILE *fp;
|
||||||
|
|
||||||
if ( ! ( fp = fopen( name, "w" ) ))
|
char *tmpname;
|
||||||
|
|
||||||
|
asprintf( &tmpname, ".#%s", name );
|
||||||
|
|
||||||
|
if ( ! ( fp = fopen( tmpname, "w" ) ))
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
bool r = snapshot( fp );
|
bool r = snapshot( fp );
|
||||||
|
|
||||||
fclose( fp );
|
fclose( fp );
|
||||||
|
|
||||||
|
rename( tmpname, name );
|
||||||
|
|
||||||
|
free(tmpname);
|
||||||
|
|
||||||
return r;
|
return r;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue