Core hotlist: A NULL save_path makes the hotlist read-only.

This commit is contained in:
Michael Drake 2017-04-28 12:02:48 +01:00
parent 6c726473ef
commit 06baaa9f7c
2 changed files with 15 additions and 6 deletions

View File

@ -107,7 +107,7 @@ static nserror hotlist_get_temp_path(const char *path, char **temp_path)
/* Save the hotlist to to a file at the given path
*
* \param path Path to save hostlist file to.
* \param path Path to save hotlist file to. NULL path is a no-op.
* \return NSERROR_OK on success, or appropriate error otherwise
*/
static nserror hotlist_save(const char *path)
@ -115,6 +115,11 @@ static nserror hotlist_save(const char *path)
nserror res = NSERROR_OK;
char *temp_path;
/* NULL path is a no-op. */
if (path == NULL) {
return NSERROR_OK;
}
/* Get path to export to */
res = hotlist_get_temp_path(path, &temp_path);
if (res != NSERROR_OK) {
@ -163,7 +168,7 @@ static void hotlist_schedule_save_cb(void *p)
*/
static nserror hotlist_schedule_save(void)
{
if (hl_ctx.save_scheduled == false) {
if (hl_ctx.save_scheduled == false && hl_ctx.save_path != NULL) {
nserror err = guit->misc->schedule(10 * 1000,
hotlist_schedule_save_cb, NULL);
if (err != NSERROR_OK) {
@ -1285,9 +1290,13 @@ nserror hotlist_init(
hl_ctx.default_folder = NULL;
/* Store the save path */
hl_ctx.save_path = strdup(save_path);
if (hl_ctx.save_path == NULL) {
return NSERROR_NOMEM;
if (save_path != NULL) {
hl_ctx.save_path = strdup(save_path);
if (hl_ctx.save_path == NULL) {
return NSERROR_NOMEM;
}
} else {
hl_ctx.save_path = NULL;
}
/* Init. hotlist treeview entry fields */

View File

@ -41,7 +41,7 @@ struct rect;
* hotlist can be queried to ask if URLs are present in the hotlist.
*
* \param load_path The path to load hotlist from.
* \param save_path The path to save hotlist to.
* \param save_path The path to save hotlist to, or NULL for read-only.
* \return NSERROR_OK on success, appropriate error otherwise
*/
nserror hotlist_init(