Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
settings: return NULL if no settings path is set
  • Loading branch information
adamsutton committed Apr 13, 2014
1 parent 23515ef commit af8e79c
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 11 deletions.
3 changes: 1 addition & 2 deletions src/epggrab/module.c
Expand Up @@ -428,8 +428,7 @@ epggrab_module_ext_t *epggrab_module_ext_create
if (!skel) skel = calloc(1, sizeof(epggrab_module_ext_t));

/* Pass through */
snprintf(path, 512, "%s/epggrab/%s.sock",
hts_settings_get_root(), sockid);
hts_settings_buildpath(path, sizeof(path), "epggrab/%s.sock", sockid);
epggrab_module_int_create((epggrab_module_int_t*)skel,
id, name, priority, path,
NULL, parse, trans,
Expand Down
2 changes: 1 addition & 1 deletion src/settings.c
Expand Up @@ -41,7 +41,7 @@ static char *settingspath = NULL;
const char *
hts_settings_get_root(void)
{
return settingspath ?: "No settings dir";
return settingspath;
}

/**
Expand Down
18 changes: 10 additions & 8 deletions src/timeshift/timeshift_filemgr.c
Expand Up @@ -110,23 +110,25 @@ static void timeshift_reaper_remove ( timeshift_file_t *tsf )
*
* TODO: should this be fixed on startup?
*/
static void timeshift_filemgr_get_root ( char *buf, size_t len )
static int
timeshift_filemgr_get_root ( char *buf, size_t len )
{
const char *path = timeshift_path;
if (!path || !*path) {
path = hts_settings_get_root();
snprintf(buf, len, "%s/timeshift/buffer", path);
return hts_settings_buildpath(buf, len, "timeshift/buffer");
} else {
snprintf(buf, len, "%s/buffer", path);
}
return 0;
}

/*
* Create timeshift directories (for a given instance)
*/
int timeshift_filemgr_makedirs ( int index, char *buf, size_t len )
{
timeshift_filemgr_get_root(buf, len);
if (timeshift_filemgr_get_root(buf, len))
return 1;
snprintf(buf+strlen(buf), len-strlen(buf), "/%d", index);
return makedirs(buf, 0700);
}
Expand Down Expand Up @@ -333,8 +335,8 @@ void timeshift_filemgr_init ( void )
char path[512];

/* Try to remove any rubbish left from last run */
timeshift_filemgr_get_root(path, sizeof(path));
rmtree(path);
if(!timeshift_filemgr_get_root(path, sizeof(path)))
rmtree(path);

/* Size processing */
timeshift_total_size = 0;
Expand Down Expand Up @@ -363,8 +365,8 @@ void timeshift_filemgr_term ( void )
pthread_join(timeshift_reaper_thread, NULL);

/* Remove the lot */
timeshift_filemgr_get_root(path, sizeof(path));
rmtree(path);
if (!timeshift_filemgr_get_root(path, sizeof(path)))
rmtree(path);
}


0 comments on commit af8e79c

Please sign in to comment.