Ignore:
Timestamp:
Feb 7, 2010, 10:17:42 PM (13 years ago)
Author:
charles
Message:

(trunk daemon) #2877 "Don't let the daemon launch if settings.json is corrupt" -- implemented in trunk for 1.90

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/libtransmission/session.c

    r10129 r10135  
    1212
    1313#include <assert.h>
     14#include <errno.h> /* ENOENT */
    1415#include <stdlib.h>
    1516#include <string.h> /* memcpy */
     
    363364tr_sessionLoadSettings( tr_benc * d, const char * configDir, const char * appName )
    364365{
     366    int err = 0;
    365367    char * filename;
    366368    tr_benc fileSettings;
     
    384386    /* file settings override the defaults */
    385387    filename = tr_buildPath( configDir, "settings.json", NULL );
    386     if( !tr_bencLoadFile( &fileSettings, TR_FMT_JSON, filename ) ) {
     388    err = tr_bencLoadFile( &fileSettings, TR_FMT_JSON, filename );
     389    if( !err ) {
    387390        tr_bencMergeDicts( d, &fileSettings );
    388391        tr_bencFree( &fileSettings );
    389         success = TRUE;
    390392    }
    391393
     
    393395    tr_bencFree( &sessionDefaults );
    394396    tr_free( filename );
     397    success = (err==0) || (err==ENOENT);
    395398    return success;
    396399}
     
    411414    {
    412415        tr_benc fileSettings;
    413         if( !tr_bencLoadFile( &fileSettings, TR_FMT_JSON, filename ) )
     416        const int err = tr_bencLoadFile( &fileSettings, TR_FMT_JSON, filename );
     417        if( !err )
    414418        {
    415419            tr_bencMergeDicts( &settings, &fileSettings );
     
    432436    /* save the result */
    433437    tr_bencToFile( &settings, TR_FMT_JSON, filename );
    434     tr_inf( "Saved \"%s\"", filename );
    435438
    436439    /* cleanup */
Note: See TracChangeset for help on using the changeset viewer.