(trunk libT) #3172 "transmission overwrites settings.json" -- fixed with kklimonda's patch for 2.00
This commit is contained in:
parent
8104f4a960
commit
31f4d24004
|
@ -11,11 +11,12 @@
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#include <assert.h>
|
#include <assert.h>
|
||||||
#include <ctype.h> /* isdigit */
|
#include <ctype.h> /* isdigit() */
|
||||||
#include <errno.h>
|
#include <errno.h>
|
||||||
#include <math.h> /* fabs */
|
#include <limits.h> /* PATH_MAX */
|
||||||
|
#include <math.h> /* fabs() */
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
#include <stdlib.h>
|
#include <stdlib.h> /* realpath() */
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
|
|
||||||
#include <sys/types.h> /* stat() */
|
#include <sys/types.h> /* stat() */
|
||||||
|
@ -23,7 +24,7 @@
|
||||||
#include <locale.h>
|
#include <locale.h>
|
||||||
#include <unistd.h> /* stat(), close() */
|
#include <unistd.h> /* stat(), close() */
|
||||||
|
|
||||||
#include <event.h> /* evbuffer */
|
#include <event.h> /* struct evbuffer */
|
||||||
|
|
||||||
#include "ConvertUTF.h"
|
#include "ConvertUTF.h"
|
||||||
|
|
||||||
|
@ -1620,6 +1621,12 @@ tr_bencToFile( const tr_benc * top, tr_fmt_mode mode, const char * filename )
|
||||||
char * tmp;
|
char * tmp;
|
||||||
int fd;
|
int fd;
|
||||||
int err = 0;
|
int err = 0;
|
||||||
|
char buf[PATH_MAX];
|
||||||
|
|
||||||
|
/* follow symlinks to find the "real" file, to make sure the temporary
|
||||||
|
* we build with mkstemp() is created on the right partition */
|
||||||
|
if( realpath( filename, buf ) != NULL )
|
||||||
|
filename = buf;
|
||||||
|
|
||||||
/* if the file already exists, try to move it out of the way & keep it as a backup */
|
/* if the file already exists, try to move it out of the way & keep it as a backup */
|
||||||
tmp = tr_strdup_printf( "%s.tmp.XXXXXX", filename );
|
tmp = tr_strdup_printf( "%s.tmp.XXXXXX", filename );
|
||||||
|
|
Loading…
Reference in New Issue