another stupid macro gone
This commit is contained in:
parent
58461232db
commit
c3e4546917
|
|
@ -44,18 +44,13 @@
|
|||
#include "pnetlibs.h"
|
||||
#include "prun.h"
|
||||
#include "psettings.h"
|
||||
#include "psynclib.h"
|
||||
#include "psys.h"
|
||||
#include "ptimer.h"
|
||||
#include "putil.h"
|
||||
|
||||
extern PSYNC_THREAD const char *psync_thread_name;
|
||||
|
||||
#define return_error(err) \
|
||||
do { \
|
||||
psync_error = err; \
|
||||
return -1; \
|
||||
} while (0)
|
||||
|
||||
#define SQL_NO_LOCK 0
|
||||
#define SQL_READ_LOCK 1
|
||||
#define SQL_WRITE_LOCK 2
|
||||
|
|
@ -464,8 +459,10 @@ int psync_sql_connect(const char *db) {
|
|||
if (psync_sql_statement(psync_db_upgrade[i])) {
|
||||
pdbg_logf(D_ERROR, "error running statement %s on sqlite %s",
|
||||
psync_db_upgrade[i], sqlite3_libversion());
|
||||
if (IS_DEBUG)
|
||||
return_error(PERROR_DATABASE_OPEN);
|
||||
if (IS_DEBUG) {
|
||||
psync_error = PERROR_DATABASE_OPEN;
|
||||
return -1;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -108,11 +108,6 @@ static inline int psync_status_is_offline() {
|
|||
return pstatus_get(PSTATUS_TYPE_ONLINE) == PSTATUS_ONLINE_OFFLINE;
|
||||
}
|
||||
|
||||
#define return_error(err) \
|
||||
do { \
|
||||
psync_error = err; \
|
||||
return -1; \
|
||||
} while (0)
|
||||
#define return_isyncid(err) \
|
||||
do { \
|
||||
psync_error = err; \
|
||||
|
|
@ -178,20 +173,24 @@ int psync_init() {
|
|||
if (pdbg_unlikely(!psync_database)) {
|
||||
if (IS_DEBUG)
|
||||
pthread_mutex_unlock(&psync_libstate_mutex);
|
||||
return_error(PERROR_NO_HOMEDIR);
|
||||
|
||||
psync_error = PERROR_NO_HOMEDIR;
|
||||
return -1;
|
||||
}
|
||||
}
|
||||
if (psync_sql_connect(psync_database)) {
|
||||
if (IS_DEBUG)
|
||||
pthread_mutex_unlock(&psync_libstate_mutex);
|
||||
return_error(PERROR_DATABASE_OPEN);
|
||||
psync_error = PERROR_DATABASE_OPEN;
|
||||
return -1;
|
||||
}
|
||||
psync_sql_statement("UPDATE task SET inprogress=0 WHERE inprogress=1");
|
||||
ptimer_init();
|
||||
if (pdbg_unlikely(pssl_init())) {
|
||||
if (IS_DEBUG)
|
||||
pthread_mutex_unlock(&psync_libstate_mutex);
|
||||
return_error(PERROR_SSL_INIT_FAILED);
|
||||
psync_error = PERROR_SSL_INIT_FAILED;
|
||||
return -1;
|
||||
}
|
||||
|
||||
psync_libs_init();
|
||||
|
|
@ -755,16 +754,19 @@ int psync_add_sync_by_path_delayed(const char *localpath,
|
|||
int unsigned mbedtls_md;
|
||||
if (pdbg_unlikely(synctype < PSYNC_SYNCTYPE_MIN ||
|
||||
synctype > PSYNC_SYNCTYPE_MAX))
|
||||
return_error(PERROR_INVALID_SYNCTYPE);
|
||||
psync_error = PERROR_INVALID_SYNCTYPE;
|
||||
return -1;
|
||||
if (pdbg_unlikely(stat(localpath, &st)) ||
|
||||
pdbg_unlikely(!pfile_stat_isfolder(&st)))
|
||||
return_error(PERROR_LOCAL_FOLDER_NOT_FOUND);
|
||||
psync_error = PERROR_LOCAL_FOLDER_NOT_FOUND;
|
||||
return -1;
|
||||
if (synctype & PSYNC_DOWNLOAD_ONLY)
|
||||
mbedtls_md = 7;
|
||||
else
|
||||
mbedtls_md = 5;
|
||||
if (pdbg_unlikely(!pfile_stat_mode_ok(&st, mbedtls_md)))
|
||||
return_error(PERROR_LOCAL_FOLDER_ACC_DENIED);
|
||||
psync_error = PERROR_LOCAL_FOLDER_ACC_DENIED;
|
||||
return -1;
|
||||
res = psync_sql_prep_statement("INSERT INTO syncfolderdelayed (localpath, "
|
||||
"remotepath, synctype) VALUES (?, ?, ?)");
|
||||
psync_sql_bind_string(res, 1, localpath);
|
||||
|
|
@ -797,7 +799,8 @@ int psync_change_synctype(psync_syncid_t syncid, psync_synctype_t synctype) {
|
|||
if (pdbg_unlikely(!row)) {
|
||||
psync_sql_free_result(res);
|
||||
psync_sql_rollback_transaction();
|
||||
return_error(PERROR_INVALID_SYNCID);
|
||||
psync_error = PERROR_INVALID_SYNCID;
|
||||
return -1;
|
||||
}
|
||||
folderid = psync_get_number(row[0]);
|
||||
oldsynctype = psync_get_number(row[2]);
|
||||
|
|
|
|||
Loading…
Reference in New Issue