diff --git a/src/db.c b/src/db.c index 32a51624..a4fe0ba5 100644 --- a/src/db.c +++ b/src/db.c @@ -7093,8 +7093,9 @@ db_statements_prepare(void) return 0; } +// Returns -2 if backup not enabled in config int -db_backup() +db_backup(void) { int ret; sqlite3 *backup_hdl; @@ -7114,7 +7115,7 @@ db_backup() if (realpath(db_path, resolved_dbp) == NULL || realpath(backup_path, resolved_bp) == NULL) { DPRINTF(E_LOG, L_DB, "Failed to resolve real path of db/backup path: %s\n", strerror(errno)); - goto error; + return -1; } if (strcmp(resolved_bp, resolved_dbp) == 0) @@ -7129,14 +7130,15 @@ db_backup() if (ret != SQLITE_OK) { DPRINTF(E_WARN, L_DB, "Failed to create backup '%s': %s\n", backup_path, sqlite3_errmsg(backup_hdl)); - goto error; + return -1; } backup = sqlite3_backup_init(backup_hdl, "main", hdl, "main"); if (!backup) { DPRINTF(E_WARN, L_DB, "Failed to initiate backup '%s': %s\n", backup_path, sqlite3_errmsg(backup_hdl)); - goto error; + sqlite3_close(backup_hdl); + return -1; } ret = sqlite3_backup_step(backup, -1); @@ -7148,10 +7150,7 @@ db_backup() else DPRINTF(E_WARN, L_DB, "Failed to complete backup '%s': %s (%d)\n", backup_path, sqlite3_errstr(ret), ret); - return ret; - -error: - return -1; + return 0; } int diff --git a/src/db.h b/src/db.h index 1e452685..7b3cf631 100644 --- a/src/db.h +++ b/src/db.h @@ -1017,7 +1017,7 @@ int db_watch_enum_fetchwd(struct watch_enum *we, uint32_t *wd); int -db_backup(); +db_backup(void); int db_perthread_init(void);