Increase maintainability: namespace refactors for putil, pfs, and pfs sub-modules (#176)
* Fix #103: Refactor putil to use putil_ namespace and enforce encapsulation All public functions in putil now use the putil_ prefix (e.g., putil_strdup, putil_strcat, putil_time_format, putil_base64_encode, etc.). Internal variables (normalize_table, base64_reverse_table) and the constructor remain static. Updated all 34 call-site files across pclsync accordingly. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com> * Fix #96: Refactor pfs to use pfs_ namespace and enforce encapsulation All public functions in the pfs module renamed from psync_fs_ to pfs_ (e.g., pfs_update_openfile, pfs_refresh, pfs_start, pfs_stop, etc.). Extern vars psync_fake_prefix/psync_fake_prefix_len renamed to pfs_fake_prefix/pfs_fake_prefix_len. Functions only used within pfs.c (pfs_update_openfile_fileid_locked, pfs_chown) made static. Updated all call sites across 17 files including pclsync_lib.cpp. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com> * Refactor pfsxattr to use pfs_xattr_ namespace All psync_fs_ prefixed functions in the pfsxattr module renamed to pfs_xattr_ (e.g., pfs_xattr_set, pfs_xattr_get, pfs_xattr_list, pfs_xattr_remove, pfs_xattr_file_deleted, pfs_xattr_task_to_file, etc.). Local macro psync_fs_set_thread_name renamed to pfs_xattr_set_thread_name. Internal static helpers (delete_object_id, update_object_id, xattr_get_object_id_locked) remain static and unchanged. Updated all call sites in pfs.c, pfsupload.c, and pdiff.c. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com> * Rename pfs_xattr_ namespace to pfs_xatr_ Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com> * Refactor pfs sub-modules to use namespaced function prefixes - pfscrypto_* → pfs_crpt_* - psync_fsstatic_* → pfs_stat_* - psync_fsupload_* → pfs_upld_* - psync_fstask_* → pfs_task_* (functions only; typedefs unchanged) - psync_fsfolder_*/psync_fsfolderid_*/psync_fsfolderflags_*/ get_decname_for_folder/psync_get_folderid → pfs_fldr_* Type names, macro constants, and typedef aliases are unchanged. Updated all call sites across 17 files. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com> --------- Co-authored-by: Levi Neely <lkn@darkstar.example.net> Co-authored-by: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
parent
d6858a0166
commit
4d64b645a1
|
|
@ -73,14 +73,14 @@ static int handle_result(const binresult *bres, uint64_t result, char **err) {
|
|||
if (strlen(errorret) == 0)
|
||||
errorret = papi_find_result2(bres, "message", PARAM_STR)->str;
|
||||
|
||||
*err = psync_strndup(errorret, strlen(errorret));
|
||||
*err = putil_strndup(errorret, strlen(errorret));
|
||||
pdbg_logf(D_WARNING, "command gettreepublink returned error code %u message %s",
|
||||
(unsigned)result, errorret);
|
||||
psync_process_api_error(result);
|
||||
if (psync_handle_api_result(result) == PSYNC_NET_TEMPFAIL)
|
||||
return -result;
|
||||
else {
|
||||
*err = psync_strndup("Connection error.", 17);
|
||||
*err = putil_strndup("Connection error.", 17);
|
||||
return -1;
|
||||
}
|
||||
}
|
||||
|
|
@ -365,7 +365,7 @@ void get_ba_member_email(uint64_t userid, char **email /*OUT*/,
|
|||
const char *resret =
|
||||
papi_find_result2(users->array[0], "email", PARAM_STR)->str;
|
||||
*length = strlen(resret);
|
||||
*email = psync_strndup(resret, *length);
|
||||
*email = putil_strndup(resret, *length);
|
||||
fname = papi_find_result2(users->array[0], "firstname", PARAM_STR)->str;
|
||||
lname = papi_find_result2(users->array[0], "lastname", PARAM_STR)->str;
|
||||
}
|
||||
|
|
@ -430,7 +430,7 @@ void get_ba_team_name(uint64_t teamid, char **name /*OUT*/,
|
|||
const char *teamret =
|
||||
papi_find_result2(teams->array[0], "name", PARAM_STR)->str;
|
||||
*length = strlen(teamret);
|
||||
*name = psync_strndup(teamret, *length);
|
||||
*name = putil_strndup(teamret, *length);
|
||||
}
|
||||
free(bres);
|
||||
|
||||
|
|
|
|||
|
|
@ -244,10 +244,10 @@ static int download_keys(unsigned char **rsapriv, size_t *rsaprivlen, unsigned c
|
|||
return pdbg_return_const(PSYNC_CRYPTO_START_UNKNOWN_ERROR);
|
||||
}
|
||||
data = papi_find_result2(res, "privatekey", PARAM_STR);
|
||||
rsaprivstruct = psync_base64_decode((const unsigned char *)data->str,
|
||||
rsaprivstruct = putil_base64_decode((const unsigned char *)data->str,
|
||||
data->length, &rsaprivstructlen);
|
||||
data = papi_find_result2(res, "publickey", PARAM_STR);
|
||||
rsapubstruct = psync_base64_decode((const unsigned char *)data->str,
|
||||
rsapubstruct = putil_base64_decode((const unsigned char *)data->str,
|
||||
data->length, &rsapubstructlen);
|
||||
free(res);
|
||||
sha1hex(rsaprivstruct, rsaprivstructlen, privatesha1);
|
||||
|
|
@ -337,11 +337,11 @@ setup_upload(const unsigned char *rsapriv, size_t rsaprivlen,
|
|||
sha1hex(priv, offsetof(priv_key_ver1, key) + rsaprivlen,
|
||||
privatesha1);
|
||||
sha1hex(pub, offsetof(pub_key_ver1, key) + rsapublen, publicsha1);
|
||||
b64priv = psync_base64_encode((unsigned char *)priv,
|
||||
b64priv = putil_base64_encode((unsigned char *)priv,
|
||||
offsetof(priv_key_ver1, key) + rsaprivlen,
|
||||
&b64privlen);
|
||||
b64pub =
|
||||
psync_base64_encode((unsigned char *)pub,
|
||||
putil_base64_encode((unsigned char *)pub,
|
||||
offsetof(pub_key_ver1, key) + rsapublen, &b64publen);
|
||||
free(priv);
|
||||
free(pub);
|
||||
|
|
@ -487,7 +487,7 @@ int pcryptofolder_get_hint(char **hint) {
|
|||
}
|
||||
return pdbg_return_const(PSYNC_CRYPTO_HINT_UNKNOWN_ERROR);
|
||||
}
|
||||
*hint = psync_strdup(papi_find_result2(res, "hint", PARAM_STR)->str);
|
||||
*hint = putil_strdup(papi_find_result2(res, "hint", PARAM_STR)->str);
|
||||
free(res);
|
||||
return PSYNC_CRYPTO_HINT_SUCCESS;
|
||||
}
|
||||
|
|
@ -683,12 +683,12 @@ int pcryptofolder_unlock(const char *password) {
|
|||
return PSYNC_CRYPTO_START_SUCCESS;
|
||||
}
|
||||
|
||||
static void psync_fs_refresh_crypto_folders() {
|
||||
static void pfs_refresh_crypto_folders() {
|
||||
psync_folderid_t *fids, *fid;
|
||||
fids = psync_crypto_folderids();
|
||||
fid = fids;
|
||||
while (*fid != PSYNC_CRYPTO_INVALID_FOLDERID) {
|
||||
psync_fs_refresh_folder(*fid);
|
||||
pfs_refresh_folder(*fid);
|
||||
fid++;
|
||||
}
|
||||
free(fids);
|
||||
|
|
@ -709,7 +709,7 @@ int pcryptofolder_lock() {
|
|||
pthread_rwlock_unlock(&crypto_lock);
|
||||
pdbg_logf(D_NOTICE, "stopped crypto");
|
||||
pcryptofolder_cache_clean();
|
||||
psync_fs_refresh_crypto_folders();
|
||||
pfs_refresh_crypto_folders();
|
||||
return PSYNC_CRYPTO_STOP_SUCCESS;
|
||||
}
|
||||
|
||||
|
|
@ -845,7 +845,7 @@ static psync_encrypted_symmetric_key_t download_fldr_enckey(psync_folderid_t fol
|
|||
pdbg_return_const(PSYNC_CRYPTO_API_ERR_INTERNAL));
|
||||
}
|
||||
b64key = papi_find_result2(res, "key", PARAM_STR);
|
||||
key = psync_base64_decode((const unsigned char *)b64key->str, b64key->length,
|
||||
key = putil_base64_decode((const unsigned char *)b64key->str, b64key->length,
|
||||
&keylen);
|
||||
free(res);
|
||||
if (!key)
|
||||
|
|
@ -898,7 +898,7 @@ static psync_encrypted_symmetric_key_t download_file_enckey(psync_fileid_t filei
|
|||
}
|
||||
result = papi_find_result2(res, "hash", PARAM_NUM)->num;
|
||||
b64key = papi_find_result2(res, "key", PARAM_STR);
|
||||
key = psync_base64_decode((const unsigned char *)b64key->str, b64key->length,
|
||||
key = putil_base64_decode((const unsigned char *)b64key->str, b64key->length,
|
||||
&keylen);
|
||||
free(res);
|
||||
if (!key)
|
||||
|
|
@ -1136,7 +1136,7 @@ static pcrypto_textenc_t get_tmp_fldrencoder_safe(psync_fsfolderid_t folderid) {
|
|||
pdbg_return_const(PSYNC_CRYPTO_FOLDER_NOT_ENCRYPTED));
|
||||
}
|
||||
b64enckey = (const unsigned char *)psync_get_lstring(row[0], &b64enckeylen);
|
||||
enckey = psync_base64_decode(b64enckey, b64enckeylen, &enckeylen);
|
||||
enckey = putil_base64_decode(b64enckey, b64enckeylen, &enckeylen);
|
||||
psql_free(res);
|
||||
if (enckey) {
|
||||
symkey = prsa_decrypt_data(crypto_privkey, enckey, enckeylen);
|
||||
|
|
@ -1192,7 +1192,7 @@ static pcrypto_textdec_t get_tmp_fldrdecoder_safe(psync_fsfolderid_t folderid) {
|
|||
pdbg_return_const(PSYNC_CRYPTO_FOLDER_NOT_ENCRYPTED));
|
||||
}
|
||||
b64enckey = (const unsigned char *)psync_get_lstring(row[0], &b64enckeylen);
|
||||
enckey = psync_base64_decode(b64enckey, b64enckeylen, &enckeylen);
|
||||
enckey = putil_base64_decode(b64enckey, b64enckeylen, &enckeylen);
|
||||
psql_free(res);
|
||||
if (enckey) {
|
||||
symkey = prsa_decrypt_data(crypto_privkey, enckey, enckeylen);
|
||||
|
|
@ -1282,7 +1282,7 @@ char *pcryptofolder_flddecode_filename(pcrypto_textdec_t decoder,
|
|||
const char *name) {
|
||||
unsigned char *filenameenc, *filenamedec;
|
||||
size_t filenameenclen;
|
||||
filenameenc = psync_base32_decode((const unsigned char *)name, strlen(name),
|
||||
filenameenc = putil_base32_decode((const unsigned char *)name, strlen(name),
|
||||
&filenameenclen);
|
||||
if (!filenameenc)
|
||||
return NULL;
|
||||
|
|
@ -1353,7 +1353,7 @@ char * pcryptofolder_fldencode_filename(pcrypto_textenc_t encoder,
|
|||
pcrypto_encode_text(encoder, (const unsigned char *)name,
|
||||
strlen(name), &filenameenc, &filenameenclen);
|
||||
filenameb32 =
|
||||
psync_base32_encode(filenameenc, filenameenclen, &filenameenclen);
|
||||
putil_base32_encode(filenameenc, filenameenclen, &filenameenclen);
|
||||
free(filenameenc);
|
||||
return (char *)filenameb32;
|
||||
}
|
||||
|
|
@ -1421,7 +1421,7 @@ static pcrypto_sector_encdec_t get_fileencoder_tmp(psync_fsfileid_t fileid,
|
|||
switch (psync_get_number(row[0])) {
|
||||
case PSYNC_FS_TASK_CREAT:
|
||||
b64enckey = (const unsigned char *)psync_get_lstring(row[2], &b64enckeylen);
|
||||
enckey = psync_base64_decode(b64enckey, b64enckeylen, &enckeylen);
|
||||
enckey = putil_base64_decode(b64enckey, b64enckeylen, &enckeylen);
|
||||
psql_free(res);
|
||||
if (enckey) {
|
||||
symkey = prsa_decrypt_data(crypto_privkey, enckey, enckeylen);
|
||||
|
|
@ -1504,7 +1504,7 @@ pcrypto_sector_encdec_t pcryptofolder_filencoder_from_binresult(psync_fileid_t f
|
|||
uint64_t hash;
|
||||
size_t keylen;
|
||||
b64key = papi_find_result2(res, "key", PARAM_STR);
|
||||
key = psync_base64_decode((const unsigned char *)b64key->str, b64key->length,
|
||||
key = putil_base64_decode((const unsigned char *)b64key->str, b64key->length,
|
||||
&keylen);
|
||||
if (!key)
|
||||
return (pcrypto_sector_encdec_t)errptr(
|
||||
|
|
@ -1560,7 +1560,7 @@ static char *get_name_encoded(psync_folderid_t folderid,
|
|||
return (char *)enc;
|
||||
pcrypto_encode_text(enc, (const unsigned char *)name,
|
||||
strlen(name), &nameenc, &nameenclen);
|
||||
ret = (char *)psync_base32_encode(nameenc, nameenclen, &nameenclen);
|
||||
ret = (char *)putil_base32_encode(nameenc, nameenclen, &nameenclen);
|
||||
free_direncoder(folderid, enc);
|
||||
free(nameenc);
|
||||
return ret;
|
||||
|
|
@ -1597,7 +1597,7 @@ static int get_fldr_name(psync_folderid_t folderid,
|
|||
const char *name, char **ename,
|
||||
const char **err) {
|
||||
if (folderid == 0) {
|
||||
*ename = psync_strdup(name);
|
||||
*ename = putil_strdup(name);
|
||||
return PSYNC_CRYPTO_SUCCESS;
|
||||
} else {
|
||||
psync_sql_res *res;
|
||||
|
|
@ -1613,7 +1613,7 @@ static int get_fldr_name(psync_folderid_t folderid,
|
|||
if (enc)
|
||||
return get_cfldr_name(folderid, name, ename, err);
|
||||
else {
|
||||
*ename = psync_strdup(name);
|
||||
*ename = putil_strdup(name);
|
||||
return PSYNC_CRYPTO_SUCCESS;
|
||||
}
|
||||
}
|
||||
|
|
@ -1681,7 +1681,7 @@ char *pcryptofolder_filencoder_key_get(psync_fsfileid_t fileid,
|
|||
encsym = get_file_enckey(fileid, hash, 0);
|
||||
if (is_err(encsym))
|
||||
return (char *)encsym;
|
||||
ret = (char *)psync_base64_encode(encsym->data, encsym->datalen, keylen);
|
||||
ret = (char *)putil_base64_encode(encsym->data, encsym->datalen, keylen);
|
||||
free(encsym);
|
||||
return ret;
|
||||
}
|
||||
|
|
@ -1709,7 +1709,7 @@ char *pcryptofolder_filencoder_key_new(uint32_t flags, size_t *keylen) {
|
|||
return (char *)errptr(pdbg_return_const(PSYNC_CRYPTO_RSA_ERROR));
|
||||
}
|
||||
putil_wipe(&sym, sizeof(sym));
|
||||
ret = (char *)psync_base64_encode(encsym->data, encsym->datalen, keylen);
|
||||
ret = (char *)putil_base64_encode(encsym->data, encsym->datalen, keylen);
|
||||
free(encsym);
|
||||
return ret;
|
||||
}
|
||||
|
|
@ -1739,7 +1739,7 @@ char *pcryptofolder_filencoder_key_newplain(
|
|||
}
|
||||
*deckey = symkeyv1_to_symkey(&sym);
|
||||
putil_wipe(&sym, sizeof(sym));
|
||||
ret = (char *)psync_base64_encode(encsym->data, encsym->datalen, keylen);
|
||||
ret = (char *)putil_base64_encode(encsym->data, encsym->datalen, keylen);
|
||||
free(encsym);
|
||||
return ret;
|
||||
}
|
||||
|
|
@ -1779,7 +1779,7 @@ int pcryptofolder_mkdir(psync_folderid_t folderid, const char *name,
|
|||
pdbg_logf(D_ERROR, "RSA encryption failed");
|
||||
return set_err(pdbg_return_const(PSYNC_CRYPTO_RSA_ERROR), err);
|
||||
}
|
||||
b64encsym = psync_base64_encode(encsym->data, encsym->datalen, &b64encsymlen);
|
||||
b64encsym = putil_base64_encode(encsym->data, encsym->datalen, &b64encsymlen);
|
||||
ret = psync_cloud_crypto_send_mkdir(folderid, ename, err, (char *)b64encsym,
|
||||
b64encsymlen, encsym, newfolderid);
|
||||
free(encsym);
|
||||
|
|
@ -1888,8 +1888,8 @@ int psync_pcloud_crypto_reencode_key(
|
|||
prsa_free_private(priv);
|
||||
return to_err(rsasign);
|
||||
}
|
||||
*privenc = (char *)psync_base64_encode(newpriv, newprivlen, &dummy);
|
||||
*sign = (char *)psync_base64_encode(rsasign->data, rsasign->datalen, &dummy);
|
||||
*privenc = (char *)putil_base64_encode(newpriv, newprivlen, &dummy);
|
||||
*sign = (char *)putil_base64_encode(rsasign->data, rsasign->datalen, &dummy);
|
||||
free(rsasign);
|
||||
free(newpriv);
|
||||
prsa_free_public(pub);
|
||||
|
|
@ -1963,8 +1963,8 @@ int psync_pcloud_crypto_encode_key(const char *newpassphrase, uint32_t flags,
|
|||
prsa_free_binary(rsapriv);
|
||||
return to_err(rsasign);
|
||||
}
|
||||
*privenc = (char *)psync_base64_encode(newpriv, rsaprivlen, &dummy);
|
||||
*sign = (char *)psync_base64_encode(rsasign->data, rsasign->datalen, &dummy);
|
||||
*privenc = (char *)putil_base64_encode(newpriv, rsaprivlen, &dummy);
|
||||
*sign = (char *)putil_base64_encode(rsasign->data, rsasign->datalen, &dummy);
|
||||
free(rsasign);
|
||||
putil_wipe(newpriv, rsaprivlen);
|
||||
free(newpriv);
|
||||
|
|
@ -2069,13 +2069,13 @@ int pcryptofolder_change_pass(const char *oldpassphrase,
|
|||
}
|
||||
pdbg_logf(D_NOTICE, "downloaded user keys");
|
||||
data = papi_find_result2(bres, "privatekey", PARAM_STR);
|
||||
privkey = psync_base64_decode((const unsigned char *)data->str,
|
||||
privkey = putil_base64_decode((const unsigned char *)data->str,
|
||||
data->length, &privkeylen);
|
||||
data = papi_find_result2(bres, "publickey", PARAM_STR);
|
||||
pubkey = psync_base64_decode((const unsigned char *)data->str, data->length,
|
||||
pubkey = putil_base64_decode((const unsigned char *)data->str, data->length,
|
||||
&pubkeylen);
|
||||
data = papi_find_result2(bres, "salt", PARAM_STR);
|
||||
salt = psync_base64_decode((const unsigned char *)data->str, data->length,
|
||||
salt = putil_base64_decode((const unsigned char *)data->str, data->length,
|
||||
&saltlen);
|
||||
free(bres);
|
||||
if (unlikely(!privkey || !pubkey)) {
|
||||
|
|
|
|||
|
|
@ -88,7 +88,7 @@ char *psync_debug_path() {
|
|||
return sockpath;
|
||||
}
|
||||
|
||||
char *psync_fs_event_log_path() {
|
||||
char *pfs_event_log_path() {
|
||||
const char *custom_path = getenv("PCLOUD_FS_EVENT_LOG");
|
||||
if (custom_path && custom_path[0] != '\0') {
|
||||
size_t len = strlen(custom_path) + 1;
|
||||
|
|
@ -148,7 +148,7 @@ int pdbg_printf(const char *file, const char *function, int unsigned line, int u
|
|||
/* Create empty fs event log file on first call if configured */
|
||||
if (unlikely(!fs_event_log_initialized)) {
|
||||
fs_event_log_initialized = 1;
|
||||
char *path = psync_fs_event_log_path();
|
||||
char *path = pfs_event_log_path();
|
||||
if (path) {
|
||||
/* Create empty file if it doesn't exist, or open existing */
|
||||
FILE *f = fopen(path, "a+");
|
||||
|
|
@ -160,7 +160,7 @@ int pdbg_printf(const char *file, const char *function, int unsigned line, int u
|
|||
}
|
||||
|
||||
clock_gettime(CLOCK_REALTIME, &ts);
|
||||
time_format(ts.tv_sec, ts.tv_nsec, dttime);
|
||||
putil_time_format(ts.tv_sec, ts.tv_nsec, dttime);
|
||||
threadid = pthread_self();
|
||||
memcpy(&u, &threadid, sizeof(u));
|
||||
snprintf(format, sizeof(format), "%s %u %s %s: %s:%u (function %s): %s\n",
|
||||
|
|
@ -208,7 +208,7 @@ static void do_reopen_log() {
|
|||
fclose(fs_event_log);
|
||||
fs_event_log = NULL;
|
||||
|
||||
path = psync_fs_event_log_path();
|
||||
path = pfs_event_log_path();
|
||||
if (path) {
|
||||
new_log = fopen(path, "a+");
|
||||
free(path);
|
||||
|
|
@ -235,7 +235,7 @@ void pdbg_write_fs_event(const char *fmt, ...) {
|
|||
|
||||
/* Open fs event log if not already open */
|
||||
if (unlikely(!fs_event_log)) {
|
||||
char *path = psync_fs_event_log_path();
|
||||
char *path = pfs_event_log_path();
|
||||
if (!path) {
|
||||
/* FS event log not configured, skip */
|
||||
pthread_mutex_unlock(&log_mutex);
|
||||
|
|
@ -251,7 +251,7 @@ void pdbg_write_fs_event(const char *fmt, ...) {
|
|||
|
||||
/* Get timestamp */
|
||||
clock_gettime(CLOCK_REALTIME, &ts);
|
||||
time_format(ts.tv_sec, ts.tv_nsec, dttime);
|
||||
putil_time_format(ts.tv_sec, ts.tv_nsec, dttime);
|
||||
|
||||
/* Write timestamp followed by event message */
|
||||
fprintf(fs_event_log, "%s ", dttime);
|
||||
|
|
|
|||
|
|
@ -59,7 +59,7 @@ char *pdevice_id() {
|
|||
(de->d_name[1] != 0 &&
|
||||
(de->d_name[1] != '.' || de->d_name[2] != 0))) {
|
||||
path =
|
||||
psync_strcat("/sys/class/power_supply/", de->d_name, "/type", NULL);
|
||||
putil_strcat("/sys/class/power_supply/", de->d_name, "/type", NULL);
|
||||
fd = open(path, O_RDONLY);
|
||||
free(path);
|
||||
if (fd == -1)
|
||||
|
|
@ -74,19 +74,19 @@ char *pdevice_id() {
|
|||
}
|
||||
closedir(dh);
|
||||
}
|
||||
device = psync_strcat(hardware, ", Linux", NULL);
|
||||
device = putil_strcat(hardware, ", Linux", NULL);
|
||||
return device;
|
||||
}
|
||||
|
||||
char *pdevice_name() {
|
||||
char *osname = pdevice_get_os();
|
||||
char *ret = psync_strcat(osname, ", ", psync_software_name, NULL);
|
||||
char *ret = putil_strcat(osname, ", ", psync_software_name, NULL);
|
||||
free(osname);
|
||||
return ret;
|
||||
}
|
||||
|
||||
char *pdevice_get_os() {
|
||||
return psync_os_name ? psync_strdup(psync_os_name) : pdevice_id();
|
||||
return psync_os_name ? putil_strdup(psync_os_name) : pdevice_id();
|
||||
}
|
||||
|
||||
void pdevice_set_software(const char *snm) {
|
||||
|
|
|
|||
|
|
@ -251,7 +251,7 @@ static int check_active_subscribtion(const binresult *res) {
|
|||
char *status;
|
||||
sub = papi_check_result2(res, "lastsubscription", PARAM_HASH);
|
||||
if (sub) {
|
||||
status = psync_strdup(papi_find_result2(sub, "status", PARAM_STR)->str);
|
||||
status = putil_strdup(papi_find_result2(sub, "status", PARAM_STR)->str);
|
||||
if (!strcmp(status, "active")) {
|
||||
free(status);
|
||||
return 1;
|
||||
|
|
@ -332,7 +332,7 @@ static psock_t *get_connected_socket() {
|
|||
"REPLACE INTO setting (id, value) VALUES ('deviceid', ?)");
|
||||
psql_bind_str(q, 1, deviceidhex);
|
||||
psql_run_free(q);
|
||||
deviceid = psync_strdup(deviceidhex);
|
||||
deviceid = putil_strdup(deviceidhex);
|
||||
}
|
||||
|
||||
pdbg_logf(D_NOTICE, "using deviceid %s", deviceid);
|
||||
|
|
@ -367,11 +367,11 @@ static psock_t *get_connected_socket() {
|
|||
}
|
||||
|
||||
if (!auth && psync_my_auth[0])
|
||||
auth = psync_strdup(psync_my_auth);
|
||||
auth = putil_strdup(psync_my_auth);
|
||||
if (!user && psync_my_user)
|
||||
user = psync_strdup(psync_my_user);
|
||||
user = putil_strdup(psync_my_user);
|
||||
if (!pass && psync_my_pass)
|
||||
pass = psync_strdup(psync_my_pass);
|
||||
pass = putil_strdup(psync_my_pass);
|
||||
if (!auth && (!pass || !user)) {
|
||||
if (tfa) {
|
||||
tfa = 0;
|
||||
|
|
@ -463,7 +463,7 @@ static psock_t *get_connected_socket() {
|
|||
if (result == 2297) {
|
||||
free(psync_my_2fa_token);
|
||||
psync_my_2fa_token =
|
||||
psync_strdup(papi_find_result2(res, "token", PARAM_STR)->str);
|
||||
putil_strdup(papi_find_result2(res, "token", PARAM_STR)->str);
|
||||
psync_my_2fa_has_devices =
|
||||
papi_find_result2(res, "hasdevices", PARAM_BOOL)->num;
|
||||
psync_my_2fa_type = papi_find_result2(res, "tfatype", PARAM_NUM)->num;
|
||||
|
|
@ -479,7 +479,7 @@ static psock_t *get_connected_socket() {
|
|||
if (result == 2306) {
|
||||
free(psync_my_verify_token);
|
||||
psync_my_verify_token =
|
||||
psync_strdup(papi_find_result2(res, "verifytoken", PARAM_STR)->str);
|
||||
putil_strdup(papi_find_result2(res, "verifytoken", PARAM_STR)->str);
|
||||
pstatus_set(PSTATUS_TYPE_AUTH, PSTATUS_AUTH_VERIFYREQ);
|
||||
pstatus_wait(PSTATUS_TYPE_AUTH, PSTATUS_AUTH_PROVIDED);
|
||||
psock_close(sock);
|
||||
|
|
@ -491,7 +491,7 @@ static psock_t *get_connected_socket() {
|
|||
cres = papi_check_result2(res, "location", PARAM_HASH);
|
||||
if (cres) {
|
||||
binapi =
|
||||
psync_strdup(papi_find_result2(cres, "binapi", PARAM_STR)->str);
|
||||
putil_strdup(papi_find_result2(cres, "binapi", PARAM_STR)->str);
|
||||
|
||||
locationid = papi_find_result2(cres, "id", PARAM_NUM)->num;
|
||||
psync_set_apiserver(binapi, locationid);
|
||||
|
|
@ -566,7 +566,7 @@ static psock_t *get_connected_socket() {
|
|||
psync_is_business = papi_find_result2(res, "business", PARAM_BOOL)->num;
|
||||
lid = psync_setting_get_uint(_PS(location_id));
|
||||
psql_start();
|
||||
psync_strlcpy(psync_my_auth, papi_find_result2(res, "auth", PARAM_STR)->str,
|
||||
putil_strlcpy(psync_my_auth, papi_find_result2(res, "auth", PARAM_STR)->str,
|
||||
sizeof(psync_my_auth));
|
||||
|
||||
if (luserid) {
|
||||
|
|
@ -923,7 +923,7 @@ static void process_createfolder(const binresult *entry) {
|
|||
|
||||
// Log remote folder creation (both synced and FUSE-only)
|
||||
{
|
||||
char *folderpath = psync_fs_get_path_by_folderid(folderid);
|
||||
char *folderpath = pfs_get_path_by_folderid(folderid);
|
||||
if (likely(folderpath)) {
|
||||
pdbg_write_fs_event("folder created %s", folderpath);
|
||||
free(folderpath);
|
||||
|
|
@ -1091,7 +1091,7 @@ static void process_modifyfolder(const binresult *entry) {
|
|||
}
|
||||
|
||||
// Get old folder path before database update (for move detection)
|
||||
char *oldfolderpath = psync_fs_get_path_by_folderid(folderid);
|
||||
char *oldfolderpath = pfs_get_path_by_folderid(folderid);
|
||||
char *oldfolderpath_rel = pfolder_path(folderid, NULL);
|
||||
|
||||
mtime = papi_find_result2(meta, "modified", PARAM_NUM)->num;
|
||||
|
|
@ -1111,7 +1111,7 @@ static void process_modifyfolder(const binresult *entry) {
|
|||
int is_move = (oldparentfolderid != parentfolderid ||
|
||||
strcmp(name->str, oldname) != 0);
|
||||
if (is_move) {
|
||||
char *newfolderpath = psync_fs_get_path_by_folderid(folderid);
|
||||
char *newfolderpath = pfs_get_path_by_folderid(folderid);
|
||||
if (likely(oldfolderpath && newfolderpath)) {
|
||||
pdbg_write_fs_event("folder moved %s -> %s", oldfolderpath, newfolderpath);
|
||||
}
|
||||
|
|
@ -1278,7 +1278,7 @@ static void process_deletefolder(const binresult *entry) {
|
|||
|
||||
// Get folder path BEFORE deletion from database
|
||||
path = pfolder_path(folderid, NULL);
|
||||
char *fullpath = psync_fs_get_path_by_folderid(folderid);
|
||||
char *fullpath = pfs_get_path_by_folderid(folderid);
|
||||
|
||||
if (psyncer_dl_has_folder(folderid)) {
|
||||
psyncer_dl_queue_del(folderid);
|
||||
|
|
@ -1315,7 +1315,7 @@ static void process_deletefolder(const binresult *entry) {
|
|||
psql_bind_uint(
|
||||
st2, 2, papi_find_result2(meta, "parentfolderid", PARAM_NUM)->num);
|
||||
psql_run(st2);
|
||||
psync_fs_folder_deleted(folderid);
|
||||
pfs_xatr_folder_deleted(folderid);
|
||||
}
|
||||
if (path)
|
||||
free(path);
|
||||
|
|
@ -1333,7 +1333,7 @@ static void check_for_deletedfileid(const binresult *meta) {
|
|||
res = psql_prepare("DELETE FROM file WHERE id=?");
|
||||
psql_bind_uint(res, 1, delfileid->num);
|
||||
psql_run_free(res);
|
||||
psync_fs_file_deleted(delfileid->num);
|
||||
pfs_xatr_file_deleted(delfileid->num);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -1451,7 +1451,7 @@ static void process_createfile(const binresult *entry) {
|
|||
|
||||
// Log all remote file creations (both synced and FUSE-only)
|
||||
{
|
||||
char *filepath = psync_fs_get_path_by_fileid(fileid);
|
||||
char *filepath = pfs_get_path_by_fileid(fileid);
|
||||
if (likely(filepath)) {
|
||||
pdbg_write_fs_event("file created %s", filepath);
|
||||
free(filepath);
|
||||
|
|
@ -1542,7 +1542,7 @@ static void process_modifyfile(const binresult *entry) {
|
|||
// Get old path before database update (for move detection)
|
||||
oldparentfolderid = psync_get_number(row[0]);
|
||||
oldname = psync_get_lstring(row[4], &oldnamelen);
|
||||
char *oldfilepath = psync_fs_get_path_by_fileid(fileid);
|
||||
char *oldfilepath = pfs_get_path_by_fileid(fileid);
|
||||
char *oldfilepath_rel = pfolder_file_path(fileid, NULL);
|
||||
|
||||
if (!st)
|
||||
|
|
@ -1589,7 +1589,7 @@ static void process_modifyfile(const binresult *entry) {
|
|||
int is_content_change = (hash != psync_get_number(row[3]) || size != oldsize);
|
||||
|
||||
if (is_move) {
|
||||
char *newfilepath = psync_fs_get_path_by_fileid(fileid);
|
||||
char *newfilepath = pfs_get_path_by_fileid(fileid);
|
||||
if (likely(oldfilepath && newfilepath)) {
|
||||
pdbg_write_fs_event("file moved %s -> %s", oldfilepath, newfilepath);
|
||||
}
|
||||
|
|
@ -1601,7 +1601,7 @@ static void process_modifyfile(const binresult *entry) {
|
|||
}
|
||||
free(newfilepath_rel);
|
||||
} else if (is_content_change) {
|
||||
char *filepath = psync_fs_get_path_by_fileid(fileid);
|
||||
char *filepath = pfs_get_path_by_fileid(fileid);
|
||||
if (likely(filepath)) {
|
||||
pdbg_write_fs_event("file modified %s", filepath);
|
||||
free(filepath);
|
||||
|
|
@ -1737,7 +1737,7 @@ static void process_deletefile(const binresult *entry) {
|
|||
}
|
||||
// Get path BEFORE deleting from database
|
||||
path = pfolder_file_path(fileid, NULL);
|
||||
char *fullpath = psync_fs_get_path_by_fileid(fileid);
|
||||
char *fullpath = pfs_get_path_by_fileid(fileid);
|
||||
|
||||
psql_bind_uint(st, 1, fileid);
|
||||
psql_run(st);
|
||||
|
|
@ -1751,7 +1751,7 @@ static void process_deletefile(const binresult *entry) {
|
|||
}
|
||||
if (papi_find_result2(meta, "ismine", PARAM_BOOL)->num)
|
||||
used_quota -= papi_find_result2(meta, "size", PARAM_NUM)->num;
|
||||
psync_fs_file_deleted(fileid);
|
||||
pfs_xatr_file_deleted(fileid);
|
||||
}
|
||||
if (path)
|
||||
free(path);
|
||||
|
|
@ -2827,7 +2827,7 @@ static int cmp_folderid(const void *ptr1, const void *ptr2) {
|
|||
}
|
||||
|
||||
static void psync_diff_refresh_fs_add_folder(psync_folderid_t folderid) {
|
||||
if (psync_fs_need_per_folder_refresh()) {
|
||||
if (pfs_need_per_folder_refresh()) {
|
||||
if (refresh_allocated == refresh_last) {
|
||||
if (refresh_allocated)
|
||||
refresh_allocated *= 2;
|
||||
|
|
@ -2851,7 +2851,7 @@ static void psync_diff_refresh_thread(void *ptr) {
|
|||
lastfolderid = (psync_folderid_t)-1;
|
||||
for (i = 0; i < fr->refresh_last; i++)
|
||||
if (fr->refresh_folders[i] != lastfolderid) {
|
||||
psync_fs_refresh_folder(fr->refresh_folders[i]);
|
||||
pfs_refresh_folder(fr->refresh_folders[i]);
|
||||
lastfolderid = fr->refresh_folders[i];
|
||||
}
|
||||
free(fr->refresh_folders);
|
||||
|
|
@ -2859,7 +2859,7 @@ static void psync_diff_refresh_thread(void *ptr) {
|
|||
}
|
||||
|
||||
static void psync_diff_refresh_fs(const binresult *entries) {
|
||||
if (psync_fs_need_per_folder_refresh()) {
|
||||
if (pfs_need_per_folder_refresh()) {
|
||||
const binresult *meta;
|
||||
refresh_folders_ptr_t *ptr;
|
||||
psync_folderid_t folderid, lastfolderid;
|
||||
|
|
@ -2918,7 +2918,7 @@ static void psync_run_analyze_if_needed() {
|
|||
for (i = 0; i < ARRAY_SIZE(skiptables); i++)
|
||||
if (!strcmp(srow[0], skiptables[i]))
|
||||
goto skip;
|
||||
tablenames[tablecnt++] = psync_strdup(srow[0]);
|
||||
tablenames[tablecnt++] = putil_strdup(srow[0]);
|
||||
skip:;
|
||||
}
|
||||
psql_free(res);
|
||||
|
|
@ -2926,7 +2926,7 @@ static void psync_run_analyze_if_needed() {
|
|||
while (tablecnt) {
|
||||
--tablecnt;
|
||||
pdbg_logf(D_NOTICE, "running ANALYZE on %s", tablenames[tablecnt]);
|
||||
sql = psync_strcat("ANALYZE ", tablenames[tablecnt], ";", NULL);
|
||||
sql = putil_strcat("ANALYZE ", tablenames[tablecnt], ";", NULL);
|
||||
free(tablenames[tablecnt]);
|
||||
psql_statement(sql);
|
||||
free(sql);
|
||||
|
|
@ -3068,7 +3068,7 @@ restart:
|
|||
}
|
||||
} while (result);
|
||||
|
||||
psync_fs_refresh_folder(0);
|
||||
pfs_refresh_folder(0);
|
||||
pdbg_logf(D_NOTICE, "initial sync finished");
|
||||
if (psync_diff_check_quota(sock)) {
|
||||
psock_close(sock);
|
||||
|
|
|
|||
|
|
@ -114,7 +114,7 @@ static int task_mkdir(const char *path) {
|
|||
int err;
|
||||
while (1) {
|
||||
if (likely(!mkdir(path, PSYNC_DEFAULT_POSIX_FOLDER_MODE))) { // don't change to likely_log, as it may
|
||||
// overwrite psync_fs_err;
|
||||
// overwrite pfs_err;
|
||||
psync_set_local_full(0);
|
||||
return 0;
|
||||
}
|
||||
|
|
@ -159,8 +159,8 @@ static void do_move(void *ptr, ppath_stat *st) {
|
|||
const char **arr;
|
||||
char *oldpath, *newpath;
|
||||
arr = (const char **)ptr;
|
||||
oldpath = psync_strcat(arr[0], st->name, NULL);
|
||||
newpath = psync_strcat(arr[1], st->name, NULL);
|
||||
oldpath = putil_strcat(arr[0], st->name, NULL);
|
||||
newpath = putil_strcat(arr[1], st->name, NULL);
|
||||
pfile_rename(oldpath, newpath);
|
||||
free(newpath);
|
||||
free(oldpath);
|
||||
|
|
@ -717,7 +717,7 @@ static int task_download_file(download_task_t *dt) {
|
|||
if (!stat(dt->tmpname, &st) &&
|
||||
pfile_stat_size(&st) >= PSYNC_MIN_SIZE_FOR_CHECKSUMS) {
|
||||
tmpold =
|
||||
psync_strcat(dt->localpath, "/", dt->filename,
|
||||
putil_strcat(dt->localpath, "/", dt->filename,
|
||||
"-old", PSYNC_APPEND_PARTIAL_FILES, NULL);
|
||||
if (pfile_rename_overwrite(dt->tmpname, tmpold)) {
|
||||
free(tmpold);
|
||||
|
|
@ -740,7 +740,7 @@ static int task_download_file(download_task_t *dt) {
|
|||
|
||||
hosts = papi_find_result2(res, "hosts", PARAM_ARRAY);
|
||||
requestpath = papi_find_result2(res, "path", PARAM_STR)->str;
|
||||
psync_slprintf(cookie, sizeof(cookie), "Cookie: dwltag=%s\015\012",
|
||||
putil_slprintf(cookie, sizeof(cookie), "Cookie: dwltag=%s\015\012",
|
||||
papi_find_result2(res, "dwltag", PARAM_STR)->str);
|
||||
buff = malloc(PSYNC_COPY_BUFFER_SIZE);
|
||||
http = NULL;
|
||||
|
|
@ -975,7 +975,7 @@ static int task_rename_file(psync_syncid_t oldsyncid, psync_syncid_t newsyncid,
|
|||
free(newfolder);
|
||||
return 0;
|
||||
}
|
||||
newpath = psync_strcat(newfolder, "/", newname, NULL);
|
||||
newpath = putil_strcat(newfolder, "/", newname, NULL);
|
||||
ret = 0;
|
||||
psync_stop_localscan();
|
||||
if (pfile_rename_overwrite(oldpath, newpath)) {
|
||||
|
|
@ -1198,8 +1198,8 @@ static int task_run_download_file(uint64_t taskid, psync_syncid_t syncid,
|
|||
if (pdbg_unlikely(!localpath))
|
||||
return 0;
|
||||
localname =
|
||||
psync_strcat(localpath, "/", filename, NULL);
|
||||
tmpname = psync_strcat(localpath, "/", filename,
|
||||
putil_strcat(localpath, "/", filename, NULL);
|
||||
tmpname = putil_strcat(localpath, "/", filename,
|
||||
PSYNC_APPEND_PARTIAL_FILES, NULL);
|
||||
len = strlen(filename);
|
||||
dt = (download_task_t *)malloc(offsetof(download_task_t, filename) +
|
||||
|
|
@ -1337,7 +1337,7 @@ static void task_del_folder_rec_do(const char *localpath,
|
|||
psql_bind_uint(res, 2, syncid);
|
||||
while ((vrow = psql_fetch(res))) {
|
||||
pupload_del_tasks(psync_get_number(vrow[0]));
|
||||
nm = psync_strcat(localpath, "/",
|
||||
nm = putil_strcat(localpath, "/",
|
||||
psync_get_string(vrow[1]), NULL);
|
||||
pdbg_logf(D_NOTICE, "deleting %s", nm);
|
||||
pfile_delete(nm);
|
||||
|
|
@ -1354,7 +1354,7 @@ static void task_del_folder_rec_do(const char *localpath,
|
|||
psql_bind_uint(res, 1, localfolderid);
|
||||
psql_bind_uint(res, 2, syncid);
|
||||
while ((vrow = psql_fetch(res))) {
|
||||
nm = psync_strcat(localpath, "/",
|
||||
nm = putil_strcat(localpath, "/",
|
||||
psync_get_string(vrow[1]), NULL);
|
||||
task_del_folder_rec_do(nm, psync_get_number(vrow[0]), syncid);
|
||||
free(nm);
|
||||
|
|
@ -1420,7 +1420,7 @@ static int download_task(uint64_t taskid, uint32_t type, psync_syncid_t syncid,
|
|||
for (ptr = name; *ptr; ptr++)
|
||||
if (pfile_invalid_chars[(unsigned char)*ptr]) {
|
||||
if (!vname)
|
||||
vname = psync_strdup(name);
|
||||
vname = putil_strdup(name);
|
||||
vname[ptr - name] = PSYNC_REPLACE_INV_CH_IN_FILENAMES;
|
||||
}
|
||||
if (vname) {
|
||||
|
|
|
|||
|
|
@ -419,7 +419,7 @@ int pfile_run_update(const char *path) {
|
|||
dup2(fd, STDERR_FILENO);
|
||||
close(fd);
|
||||
setsid();
|
||||
ex = psync_strcat(PSYNC_RUN_CMD " \"", path, "\"", NULL);
|
||||
ex = putil_strcat(PSYNC_RUN_CMD " \"", path, "\"", NULL);
|
||||
execl("/bin/sh", "/bin/sh", "-c", ex, NULL);
|
||||
pdbg_logf(D_ERROR, "exec of %s failed", ex);
|
||||
free(ex);
|
||||
|
|
|
|||
|
|
@ -343,7 +343,7 @@ char *psync_join_string_list(const char *sep, psync_list *lst, size_t *retlen) {
|
|||
cnt++;
|
||||
}
|
||||
if (unlikely(!cnt))
|
||||
return psync_strdup("");
|
||||
return putil_strdup("");
|
||||
seplen = strlen(sep);
|
||||
ret = str = malloc(slen + cnt * seplen + 1);
|
||||
psync_list_for_each_element(e, lst, string_list, list) {
|
||||
|
|
@ -375,7 +375,7 @@ char *pfolder_path(psync_folderid_t folderid, size_t *retlen) {
|
|||
psync_free_string_list(&folderlist);
|
||||
if (!ret[0]) {
|
||||
free(ret);
|
||||
ret = psync_strdup("/");
|
||||
ret = putil_strdup("/");
|
||||
if (retlen)
|
||||
*retlen = 1;
|
||||
}
|
||||
|
|
@ -397,7 +397,7 @@ char *pfolder_path_sep(psync_folderid_t folderid, const char *sep,
|
|||
psync_free_string_list(&folderlist);
|
||||
if (!ret[0]) {
|
||||
free(ret);
|
||||
ret = psync_strdup(sep);
|
||||
ret = putil_strdup(sep);
|
||||
if (retlen)
|
||||
*retlen = 1;
|
||||
}
|
||||
|
|
@ -649,13 +649,13 @@ pfolder_list_t *pfolder_remote_folders(psync_folderid_t folderid,
|
|||
(psync_get_number(row[4]) & PSYNC_FOLDER_FLAG_ENCRYPTED) ? 1 : 0;
|
||||
if (parentencrypted && pcryptofolder_is_unlocked()) {
|
||||
tmp = (char *)psync_get_lstring(row[2], &namelen);
|
||||
entry.name = get_decname_for_folder(folderid, tmp, namelen);
|
||||
entry.name = pfs_fldr_get_decname(folderid, tmp, namelen);
|
||||
if (!entry.name) {
|
||||
pdbg_logf(
|
||||
D_BUG,
|
||||
"Can't decrypt folder name for folderid: %lu, parent folfderid: "
|
||||
"%lu, cryptoerr: %d, encrypted name: %s. Skippping ...",
|
||||
entry.folder.folderid, folderid, psync_fsfolder_crypto_error(),
|
||||
entry.folder.folderid, folderid, pfs_fldr_crypto_error(),
|
||||
tmp);
|
||||
continue;
|
||||
}
|
||||
|
|
@ -822,12 +822,12 @@ psync_folder_list_t *pfolder_sync_folders(char *syncTypes) {
|
|||
strlens = 0;
|
||||
|
||||
if (strlen(syncTypes) > 0) {
|
||||
psync_slprintf(sql, 1024,
|
||||
putil_slprintf(sql, 1024,
|
||||
"SELECT id, folderid, localpath, synctype FROM syncfolder "
|
||||
"WHERE folderid IS NOT NULL AND synctype IN (%s)",
|
||||
syncTypes);
|
||||
} else {
|
||||
psync_slprintf(sql, 1024,
|
||||
putil_slprintf(sql, 1024,
|
||||
"SELECT id, folderid, localpath, synctype FROM syncfolder "
|
||||
"WHERE folderid IS NOT NULL");
|
||||
}
|
||||
|
|
@ -851,7 +851,7 @@ psync_folder_list_t *pfolder_sync_folders(char *syncTypes) {
|
|||
folderid = psync_get_number(row[1]);
|
||||
str = pfolder_path(folderid, &l);
|
||||
if (unlikely(!str)) {
|
||||
str = psync_strdup("/Invalid/Path");
|
||||
str = putil_strdup("/Invalid/Path");
|
||||
l = strlen(str);
|
||||
}
|
||||
l++;
|
||||
|
|
@ -945,7 +945,7 @@ psync_syncid_t pfolder_add_sync(const char *localpath, psync_folderid_t folderid
|
|||
mbedtls_md = 5;
|
||||
if (pdbg_unlikely(!pfile_stat_mode_ok(&st, mbedtls_md)))
|
||||
return_isyncid(PERROR_LOCAL_FOLDER_ACC_DENIED);
|
||||
syncmp = psync_fs_getmountpoint();
|
||||
syncmp = pfs_getmountpoint();
|
||||
if (syncmp) {
|
||||
size_t len = strlen(syncmp);
|
||||
if (!memcmp(syncmp, localpath, len) &&
|
||||
|
|
|
|||
932
pclsync/pfs.c
932
pclsync/pfs.c
File diff suppressed because it is too large
Load Diff
|
|
@ -45,11 +45,11 @@
|
|||
#include "ptimer.h"
|
||||
#include "ptree.h"
|
||||
|
||||
#define psync_fs_need_per_folder_refresh() psync_fs_need_per_folder_refresh_f()
|
||||
#define psync_fs_need_per_folder_refresh_const() 1
|
||||
#define pfs_need_per_folder_refresh() pfs_need_per_folder_refresh_f()
|
||||
#define pfs_need_per_folder_refresh_const() 1
|
||||
|
||||
extern char *psync_fake_prefix;
|
||||
extern size_t psync_fake_prefix_len;
|
||||
extern char *pfs_fake_prefix;
|
||||
extern size_t pfs_fake_prefix_len;
|
||||
|
||||
typedef struct {
|
||||
uint64_t frompage;
|
||||
|
|
@ -129,19 +129,19 @@ typedef struct {
|
|||
typedef struct {
|
||||
uint64_t offset;
|
||||
uint64_t length;
|
||||
} psync_fs_index_record;
|
||||
} pfs_index_record;
|
||||
|
||||
typedef struct {
|
||||
int dummy[0];
|
||||
} psync_fs_index_header;
|
||||
} pfs_index_header;
|
||||
|
||||
#if IS_DEBUG
|
||||
#define psync_fs_lock_file(of) psync_fs_do_lock_file(of, __FILE__, __LINE__)
|
||||
#define pfs_lock_file(of) pfs_do_lock_file(of, __FILE__, __LINE__)
|
||||
|
||||
|
||||
// FIXME: wtf...
|
||||
extern PSYNC_THREAD const char *psync_thread_name;
|
||||
static inline void psync_fs_do_lock_file(psync_openfile_t *of, const char *file,
|
||||
static inline void pfs_do_lock_file(psync_openfile_t *of, const char *file,
|
||||
unsigned long line) {
|
||||
if (unlikely(pthread_mutex_trylock(&of->mutex))) {
|
||||
struct timespec tm;
|
||||
|
|
@ -160,35 +160,35 @@ static inline void psync_fs_do_lock_file(psync_openfile_t *of, const char *file,
|
|||
of->lockline = line;
|
||||
}
|
||||
#else
|
||||
static inline void psync_fs_lock_file(psync_openfile_t *of) {
|
||||
static inline void pfs_lock_file(psync_openfile_t *of) {
|
||||
pthread_mutex_lock(&of->mutex);
|
||||
}
|
||||
#endif
|
||||
|
||||
int psync_fs_crypto_err_to_errno(int cryptoerr);
|
||||
int psync_fs_update_openfile(uint64_t taskid, uint64_t writeid,
|
||||
int pfs_crypto_err_to_errno(int cryptoerr);
|
||||
int pfs_update_openfile(uint64_t taskid, uint64_t writeid,
|
||||
psync_fileid_t newfileid, uint64_t hash,
|
||||
uint64_t size, time_t ctime);
|
||||
// void psync_fs_uploading_openfile(uint64_t taskid);
|
||||
int psync_fs_rename_openfile_locked(psync_fsfileid_t fileid,
|
||||
// void pfs_uploading_openfile(uint64_t taskid);
|
||||
int pfs_rename_openfile_locked(psync_fsfileid_t fileid,
|
||||
psync_fsfolderid_t folderid,
|
||||
const char *name);
|
||||
void psync_fs_mark_openfile_deleted(uint64_t taskid);
|
||||
int64_t psync_fs_get_file_writeid(uint64_t taskid);
|
||||
int64_t psync_fs_load_interval_tree(int fd, uint64_t size,
|
||||
void pfs_mark_openfile_deleted(uint64_t taskid);
|
||||
int64_t pfs_get_file_writeid(uint64_t taskid);
|
||||
int64_t pfs_load_interval_tree(int fd, uint64_t size,
|
||||
psync_interval_tree_t **tree);
|
||||
int psync_fs_remount();
|
||||
void psync_fs_inc_of_refcnt_locked(psync_openfile_t *of);
|
||||
void psync_fs_inc_of_refcnt(psync_openfile_t *of);
|
||||
void psync_fs_dec_of_refcnt(psync_openfile_t *of);
|
||||
void psync_fs_inc_of_refcnt_and_readers(psync_openfile_t *of);
|
||||
void psync_fs_dec_of_refcnt_and_readers(psync_openfile_t *of);
|
||||
int pfs_remount();
|
||||
void pfs_inc_of_refcnt_locked(psync_openfile_t *of);
|
||||
void pfs_inc_of_refcnt(psync_openfile_t *of);
|
||||
void pfs_dec_of_refcnt(psync_openfile_t *of);
|
||||
void pfs_inc_of_refcnt_and_readers(psync_openfile_t *of);
|
||||
void pfs_dec_of_refcnt_and_readers(psync_openfile_t *of);
|
||||
|
||||
void psync_fs_refresh();
|
||||
int psync_fs_need_per_folder_refresh_f();
|
||||
void psync_fs_refresh_folder(psync_folderid_t folderid);
|
||||
void pfs_refresh();
|
||||
int pfs_need_per_folder_refresh_f();
|
||||
void pfs_refresh_folder(psync_folderid_t folderid);
|
||||
|
||||
void psync_fs_pause_until_login();
|
||||
void psync_fs_clean_tasks();
|
||||
void pfs_pause_until_login();
|
||||
void pfs_clean_tasks();
|
||||
|
||||
#endif
|
||||
|
|
|
|||
File diff suppressed because it is too large
Load Diff
|
|
@ -53,18 +53,18 @@ typedef struct {
|
|||
|
||||
typedef pcrypto_sector_auth_t psync_crypto_auth_sector_t[PSYNC_CRYPTO_HASH_TREE_SECTORS];
|
||||
|
||||
int pfscrypto_init_log(psync_openfile_t *of);
|
||||
int pfscrypto_read_new(psync_openfile_t *of, char *buf, uint64_t size, uint64_t offset);
|
||||
int pfscrypto_write_new(psync_openfile_t *of, const char *buf, uint64_t size, uint64_t offset);
|
||||
int pfscrypto_read_mod(psync_openfile_t *of, char *buf, uint64_t size, uint64_t offset);
|
||||
int pfscrypto_write_mod(psync_openfile_t *of, const char *buf, uint64_t size, uint64_t offset);
|
||||
int pfscrypto_truncate(psync_openfile_t *of, uint64_t size);
|
||||
int pfscrypto_flush(psync_openfile_t *of);
|
||||
psync_crypto_sectorid_t pfscrypto_sector_id(psync_crypto_sectorid_t sectorid);
|
||||
void pfscrypto_offset_by_size(uint64_t size, psync_crypto_offsets_t *offsets);
|
||||
uint64_t pfscrypto_plain_size(uint64_t cryptosize);
|
||||
uint64_t pfscrypto_crypto_size(uint64_t plainsize);
|
||||
void pfscrypto_get_auth_off(psync_crypto_sectorid_t sectorid, uint32_t level, psync_crypto_offsets_t *offsets, uint64_t *offset, uint32_t *size, uint32_t *authid);
|
||||
void pfscrypto_check_logs();
|
||||
int pfs_crpt_init_log(psync_openfile_t *of);
|
||||
int pfs_crpt_read_new(psync_openfile_t *of, char *buf, uint64_t size, uint64_t offset);
|
||||
int pfs_crpt_write_new(psync_openfile_t *of, const char *buf, uint64_t size, uint64_t offset);
|
||||
int pfs_crpt_read_mod(psync_openfile_t *of, char *buf, uint64_t size, uint64_t offset);
|
||||
int pfs_crpt_write_mod(psync_openfile_t *of, const char *buf, uint64_t size, uint64_t offset);
|
||||
int pfs_crpt_truncate(psync_openfile_t *of, uint64_t size);
|
||||
int pfs_crpt_flush(psync_openfile_t *of);
|
||||
psync_crypto_sectorid_t pfs_crpt_sector_id(psync_crypto_sectorid_t sectorid);
|
||||
void pfs_crpt_offset_by_size(uint64_t size, psync_crypto_offsets_t *offsets);
|
||||
uint64_t pfs_crpt_plain_size(uint64_t cryptosize);
|
||||
uint64_t pfs_crpt_crypto_size(uint64_t plainsize);
|
||||
void pfs_crpt_get_auth_off(psync_crypto_sectorid_t sectorid, uint32_t level, psync_crypto_offsets_t *offsets, uint64_t *offset, uint32_t *size, uint32_t *authid);
|
||||
void pfs_crpt_check_logs();
|
||||
|
||||
#endif
|
||||
|
|
|
|||
|
|
@ -62,7 +62,7 @@ static char *get_encname_for_folder(psync_fsfolderid_t folderid,
|
|||
cryptoerr = psync_crypto_to_error(enc);
|
||||
return NULL;
|
||||
}
|
||||
name = psync_strndup(path, len);
|
||||
name = putil_strndup(path, len);
|
||||
encname = pcryptofolder_fldencode_filename(enc, name);
|
||||
pcryptofolder_fldencoder_release(folderid, enc);
|
||||
free(name);
|
||||
|
|
@ -74,7 +74,7 @@ static psync_fspath_t *ret_folder_data(psync_fsfolderid_t folderid,
|
|||
uint32_t flags, uint32_t shareid) {
|
||||
psync_fspath_t *ret;
|
||||
if (flags & PSYNC_FOLDER_FLAG_ENCRYPTED &&
|
||||
strncmp(psync_fake_prefix, name, psync_fake_prefix_len)) {
|
||||
strncmp(pfs_fake_prefix, name, pfs_fake_prefix_len)) {
|
||||
pcrypto_textenc_t enc;
|
||||
char *encname;
|
||||
size_t len;
|
||||
|
|
@ -105,7 +105,7 @@ static psync_fspath_t *ret_folder_data(psync_fsfolderid_t folderid,
|
|||
return ret;
|
||||
}
|
||||
|
||||
char *get_decname_for_folder(psync_fsfolderid_t folderid, const char *path,
|
||||
char *pfs_fldr_get_decname(psync_fsfolderid_t folderid, const char *path,
|
||||
size_t len) {
|
||||
char *name, *decname;
|
||||
pcrypto_textdec_t dec;
|
||||
|
|
@ -114,7 +114,7 @@ char *get_decname_for_folder(psync_fsfolderid_t folderid, const char *path,
|
|||
cryptoerr = psync_crypto_to_error(dec);
|
||||
return NULL;
|
||||
}
|
||||
name = psync_strndup(path, len);
|
||||
name = putil_strndup(path, len);
|
||||
decname = pcryptofolder_flddecode_filename(dec, name);
|
||||
pcryptofolder_flddecoder_release(folderid, dec);
|
||||
free(name);
|
||||
|
|
@ -147,7 +147,7 @@ static void check_userid(uint64_t userid, uint64_t folderid,
|
|||
do_check_userid(userid, folderid, shareid);
|
||||
}
|
||||
|
||||
psync_fspath_t *psync_fsfolder_resolve_path(const char *path) {
|
||||
psync_fspath_t *pfs_fldr_resolve_path(const char *path) {
|
||||
psync_fsfolderid_t cfolderid;
|
||||
const char *sl;
|
||||
psync_fstask_folder_t *folder;
|
||||
|
|
@ -211,10 +211,10 @@ psync_fspath_t *psync_fsfolder_resolve_path(const char *path) {
|
|||
elen = len;
|
||||
}
|
||||
row = psql_fetch_int(res);
|
||||
folder = psync_fstask_get_folder_tasks_rdlocked(cfolderid);
|
||||
folder = pfs_task_get_folder_tasks_rdlocked(cfolderid);
|
||||
if (folder) {
|
||||
char *name = psync_strndup(ename, elen);
|
||||
if ((mk = psync_fstask_find_mkdir(folder, name, 0))) {
|
||||
char *name = putil_strndup(ename, elen);
|
||||
if ((mk = pfs_task_find_mkdir(folder, name, 0))) {
|
||||
if (mk->flags & PSYNC_FOLDER_FLAG_INVISIBLE) {
|
||||
free(name);
|
||||
break;
|
||||
|
|
@ -222,7 +222,7 @@ psync_fspath_t *psync_fsfolder_resolve_path(const char *path) {
|
|||
cfolderid = mk->folderid;
|
||||
flags = mk->flags;
|
||||
hasit = 1;
|
||||
} else if (row && !psync_fstask_find_rmdir(folder, name, 0)) {
|
||||
} else if (row && !pfs_task_find_rmdir(folder, name, 0)) {
|
||||
cfolderid = row[0];
|
||||
permissions &= row[1];
|
||||
flags = row[2];
|
||||
|
|
@ -254,7 +254,7 @@ psync_fspath_t *psync_fsfolder_resolve_path(const char *path) {
|
|||
return NULL;
|
||||
}
|
||||
|
||||
psync_fsfolderid_t psync_fsfolderid_by_path(const char *path,
|
||||
psync_fsfolderid_t pfs_fldr_id_by_path(const char *path,
|
||||
uint32_t *pflags) {
|
||||
psync_fsfolderid_t cfolderid;
|
||||
const char *sl;
|
||||
|
|
@ -305,14 +305,14 @@ psync_fsfolderid_t psync_fsfolderid_by_path(const char *path,
|
|||
elen = len;
|
||||
}
|
||||
row = psql_fetch_int(res);
|
||||
folder = psync_fstask_get_folder_tasks_rdlocked(cfolderid);
|
||||
folder = pfs_task_get_folder_tasks_rdlocked(cfolderid);
|
||||
if (folder) {
|
||||
char *name = psync_strndup(ename, elen);
|
||||
if ((mk = psync_fstask_find_mkdir(folder, name, 0))) {
|
||||
char *name = putil_strndup(ename, elen);
|
||||
if ((mk = pfs_task_find_mkdir(folder, name, 0))) {
|
||||
cfolderid = mk->folderid;
|
||||
flags = mk->flags;
|
||||
hasit = 1;
|
||||
} else if (row && !psync_fstask_find_rmdir(folder, name, 0)) {
|
||||
} else if (row && !pfs_task_find_rmdir(folder, name, 0)) {
|
||||
cfolderid = row[0];
|
||||
flags = row[1];
|
||||
hasit = 1;
|
||||
|
|
@ -338,7 +338,7 @@ psync_fsfolderid_t psync_fsfolderid_by_path(const char *path,
|
|||
return PSYNC_INVALID_FSFOLDERID;
|
||||
}
|
||||
|
||||
psync_fsfolderid_t psync_fsfolderidperm_by_path(const char *path,
|
||||
psync_fsfolderid_t pfs_fldr_idperm_by_path(const char *path,
|
||||
uint32_t *pflags,
|
||||
uint32_t *pPermissions) {
|
||||
psync_fsfolderid_t cfolderid;
|
||||
|
|
@ -391,14 +391,14 @@ psync_fsfolderid_t psync_fsfolderidperm_by_path(const char *path,
|
|||
elen = len;
|
||||
}
|
||||
row = psql_fetch_int(res);
|
||||
folder = psync_fstask_get_folder_tasks_rdlocked(cfolderid);
|
||||
folder = pfs_task_get_folder_tasks_rdlocked(cfolderid);
|
||||
if (folder) {
|
||||
char *name = psync_strndup(ename, elen);
|
||||
if ((mk = psync_fstask_find_mkdir(folder, name, 0))) {
|
||||
char *name = putil_strndup(ename, elen);
|
||||
if ((mk = pfs_task_find_mkdir(folder, name, 0))) {
|
||||
cfolderid = mk->folderid;
|
||||
flags = mk->flags;
|
||||
hasit = 1;
|
||||
} else if (row && !psync_fstask_find_rmdir(folder, name, 0)) {
|
||||
} else if (row && !pfs_task_find_rmdir(folder, name, 0)) {
|
||||
cfolderid = row[0];
|
||||
flags = row[1];
|
||||
*pPermissions = row[2];
|
||||
|
|
@ -426,9 +426,9 @@ psync_fsfolderid_t psync_fsfolderidperm_by_path(const char *path,
|
|||
return PSYNC_INVALID_FSFOLDERID;
|
||||
}
|
||||
|
||||
int psync_fsfolder_crypto_error() { return cryptoerr; }
|
||||
int pfs_fldr_crypto_error() { return cryptoerr; }
|
||||
|
||||
uint32_t psync_fsfolderflags_by_id(psync_fsfolderid_t folderid,
|
||||
uint32_t pfs_fldr_flags_by_id(psync_fsfolderid_t folderid,
|
||||
uint32_t *pperm) {
|
||||
psync_sql_res *res;
|
||||
psync_uint_row row;
|
||||
|
|
@ -458,7 +458,7 @@ retry:
|
|||
return ret;
|
||||
}
|
||||
/*********************************************************************************************************************/
|
||||
psync_fsfolderid_t psync_get_folderid(psync_fsfolderid_t parent_fid,
|
||||
psync_fsfolderid_t pfs_fldr_get_folderid(psync_fsfolderid_t parent_fid,
|
||||
const char *name) {
|
||||
psync_fsfolderid_t folder_id = -1;
|
||||
psync_sql_res *res;
|
||||
|
|
|
|||
|
|
@ -47,18 +47,18 @@ typedef struct {
|
|||
uint16_t flags;
|
||||
} psync_fspath_t;
|
||||
|
||||
psync_fspath_t *psync_fsfolder_resolve_path(const char *path);
|
||||
psync_fsfolderid_t psync_fsfolderid_by_path(const char *path, uint32_t *pflags);
|
||||
psync_fsfolderid_t psync_fsfolderidperm_by_path(const char *path,
|
||||
psync_fspath_t *pfs_fldr_resolve_path(const char *path);
|
||||
psync_fsfolderid_t pfs_fldr_id_by_path(const char *path, uint32_t *pflags);
|
||||
psync_fsfolderid_t pfs_fldr_idperm_by_path(const char *path,
|
||||
uint32_t *pflags,
|
||||
uint32_t *pPermissions);
|
||||
uint32_t psync_fsfolderflags_by_id(psync_fsfolderid_t folderid,
|
||||
uint32_t pfs_fldr_flags_by_id(psync_fsfolderid_t folderid,
|
||||
uint32_t *pperm);
|
||||
int psync_fsfolder_crypto_error();
|
||||
char *get_decname_for_folder(psync_fsfolderid_t folderid, const char *path,
|
||||
int pfs_fldr_crypto_error();
|
||||
char *pfs_fldr_get_decname(psync_fsfolderid_t folderid, const char *path,
|
||||
size_t len);
|
||||
|
||||
psync_fsfolderid_t psync_get_folderid(psync_fsfolderid_t parent_fid,
|
||||
psync_fsfolderid_t pfs_fldr_get_folderid(psync_fsfolderid_t parent_fid,
|
||||
const char *name);
|
||||
|
||||
#endif
|
||||
|
|
|
|||
|
|
@ -546,9 +546,9 @@ static const unsigned char pcloudicon[] = {
|
|||
0xf9, 0x7f, 0xb2, 0x54, 0x74, 0x86, 0x8e, 0x89, 0x9f, 0x4c, 0x00, 0x00,
|
||||
0x00, 0x00, 0x49, 0x45, 0x4e, 0x44, 0xae, 0x42, 0x60, 0x82};
|
||||
|
||||
void psync_fsstatic_add_files() {
|
||||
psync_fstask_add_local_creat_static(0, ".directory", rootdir,
|
||||
void pfs_stat_add_files() {
|
||||
pfs_task_add_local_creat_static(0, ".directory", rootdir,
|
||||
strlen(rootdir));
|
||||
psync_fstask_add_local_creat_static(0, ".pcloudicon.png", pcloudicon,
|
||||
pfs_task_add_local_creat_static(0, ".pcloudicon.png", pcloudicon,
|
||||
ARRAY_SIZE(pcloudicon));
|
||||
}
|
||||
|
|
|
|||
|
|
@ -31,6 +31,6 @@
|
|||
#ifndef _PSYNC_FSSTATIC_H
|
||||
#define _PSYNC_FSSTATIC_H
|
||||
|
||||
void psync_fsstatic_add_files();
|
||||
void pfs_stat_add_files();
|
||||
|
||||
#endif
|
||||
|
|
|
|||
File diff suppressed because it is too large
Load Diff
|
|
@ -106,7 +106,7 @@ typedef struct {
|
|||
uint32_t refcnt;
|
||||
} psync_fstask_folder_t;
|
||||
|
||||
static inline size_t psync_fstask_creat_local_offset(size_t namelen) {
|
||||
static inline size_t pfs_task_creat_local_offset(size_t namelen) {
|
||||
return (offsetof(psync_fstask_creat_t, name) + namelen +
|
||||
psync_alignof(psync_fstask_local_creat_t)) /
|
||||
psync_alignof(psync_fstask_local_creat_t) *
|
||||
|
|
@ -114,115 +114,115 @@ static inline size_t psync_fstask_creat_local_offset(size_t namelen) {
|
|||
}
|
||||
|
||||
static inline psync_fstask_local_creat_t *
|
||||
psync_fstask_creat_len_get_local(psync_fstask_creat_t *cr, size_t namelen) {
|
||||
pfs_task_creat_len_get_local(psync_fstask_creat_t *cr, size_t namelen) {
|
||||
return (
|
||||
psync_fstask_local_creat_t *)(((char *)cr) +
|
||||
psync_fstask_creat_local_offset(namelen));
|
||||
pfs_task_creat_local_offset(namelen));
|
||||
}
|
||||
|
||||
static inline psync_fstask_local_creat_t *
|
||||
psync_fstask_creat_get_local(psync_fstask_creat_t *cr) {
|
||||
return psync_fstask_creat_len_get_local(cr, strlen(cr->name));
|
||||
pfs_task_creat_get_local(psync_fstask_creat_t *cr) {
|
||||
return pfs_task_creat_len_get_local(cr, strlen(cr->name));
|
||||
}
|
||||
|
||||
void psync_fstask_init();
|
||||
void pfs_task_init();
|
||||
|
||||
psync_fstask_folder_t *
|
||||
psync_fstask_get_or_create_folder_tasks(psync_fsfolderid_t folderid);
|
||||
pfs_task_get_or_create_folder_tasks(psync_fsfolderid_t folderid);
|
||||
psync_fstask_folder_t *
|
||||
psync_fstask_get_folder_tasks(psync_fsfolderid_t folderid);
|
||||
void psync_fstask_release_folder_tasks(psync_fstask_folder_t *folder);
|
||||
pfs_task_get_folder_tasks(psync_fsfolderid_t folderid);
|
||||
void pfs_task_release_folder_tasks(psync_fstask_folder_t *folder);
|
||||
psync_fstask_folder_t *
|
||||
psync_fstask_get_ref_locked(psync_fstask_folder_t *folder);
|
||||
pfs_task_get_ref_locked(psync_fstask_folder_t *folder);
|
||||
psync_fstask_folder_t *
|
||||
psync_fstask_get_or_create_folder_tasks_locked(psync_fsfolderid_t folderid);
|
||||
pfs_task_get_or_create_folder_tasks_locked(psync_fsfolderid_t folderid);
|
||||
psync_fstask_folder_t *
|
||||
psync_fstask_get_folder_tasks_locked(psync_fsfolderid_t folderid);
|
||||
pfs_task_get_folder_tasks_locked(psync_fsfolderid_t folderid);
|
||||
psync_fstask_folder_t *
|
||||
psync_fstask_get_folder_tasks_rdlocked(psync_fsfolderid_t folderid);
|
||||
void psync_fstask_release_folder_tasks_locked(psync_fstask_folder_t *folder);
|
||||
pfs_task_get_folder_tasks_rdlocked(psync_fsfolderid_t folderid);
|
||||
void pfs_task_release_folder_tasks_locked(psync_fstask_folder_t *folder);
|
||||
|
||||
void psync_fstask_folder_created(psync_folderid_t parentfolderid,
|
||||
void pfs_task_folder_created(psync_folderid_t parentfolderid,
|
||||
uint64_t taskid, psync_folderid_t folderid,
|
||||
const char *name);
|
||||
void psync_fstask_folder_deleted(psync_folderid_t parentfolderid,
|
||||
void pfs_task_folder_deleted(psync_folderid_t parentfolderid,
|
||||
uint64_t taskid, const char *name);
|
||||
void psync_fstask_file_created(psync_folderid_t parentfolderid, uint64_t taskid,
|
||||
void pfs_task_file_created(psync_folderid_t parentfolderid, uint64_t taskid,
|
||||
const char *name, psync_fileid_t fileid);
|
||||
void psync_fstask_file_modified(psync_folderid_t parentfolderid,
|
||||
void pfs_task_file_modified(psync_folderid_t parentfolderid,
|
||||
uint64_t taskid, const char *name,
|
||||
psync_fileid_t fileid);
|
||||
void psync_fstask_file_deleted(psync_folderid_t parentfolderid, uint64_t taskid,
|
||||
void pfs_task_file_deleted(psync_folderid_t parentfolderid, uint64_t taskid,
|
||||
const char *name);
|
||||
void psync_fstask_file_renamed(psync_folderid_t folderid, uint64_t taskid,
|
||||
void pfs_task_file_renamed(psync_folderid_t folderid, uint64_t taskid,
|
||||
const char *name, uint64_t frtaskid);
|
||||
void psync_fstask_folder_renamed(psync_folderid_t parentfolderid,
|
||||
void pfs_task_folder_renamed(psync_folderid_t parentfolderid,
|
||||
uint64_t taskid, const char *name,
|
||||
uint64_t frtaskid);
|
||||
|
||||
psync_fstask_mkdir_t *psync_fstask_find_mkdir(psync_fstask_folder_t *folder,
|
||||
psync_fstask_mkdir_t *pfs_task_find_mkdir(psync_fstask_folder_t *folder,
|
||||
const char *name,
|
||||
uint64_t taskid);
|
||||
psync_fstask_rmdir_t *psync_fstask_find_rmdir(psync_fstask_folder_t *folder,
|
||||
psync_fstask_rmdir_t *pfs_task_find_rmdir(psync_fstask_folder_t *folder,
|
||||
const char *name,
|
||||
uint64_t taskid);
|
||||
psync_fstask_creat_t *psync_fstask_find_creat(psync_fstask_folder_t *folder,
|
||||
psync_fstask_creat_t *pfs_task_find_creat(psync_fstask_folder_t *folder,
|
||||
const char *name,
|
||||
uint64_t taskid);
|
||||
psync_fstask_unlink_t *psync_fstask_find_unlink(psync_fstask_folder_t *folder,
|
||||
psync_fstask_unlink_t *pfs_task_find_unlink(psync_fstask_folder_t *folder,
|
||||
const char *name,
|
||||
uint64_t taskid);
|
||||
|
||||
psync_fstask_mkdir_t *
|
||||
psync_fstask_find_mkdir_by_folderid(psync_fstask_folder_t *folder,
|
||||
pfs_task_find_mkdir_by_folderid(psync_fstask_folder_t *folder,
|
||||
psync_fsfolderid_t folderid);
|
||||
psync_fstask_creat_t *
|
||||
psync_fstask_find_creat_by_fileid(psync_fstask_folder_t *folder,
|
||||
pfs_task_find_creat_by_fileid(psync_fstask_folder_t *folder,
|
||||
psync_fsfileid_t fileid);
|
||||
|
||||
int psync_fstask_mkdir(psync_fsfolderid_t folderid, const char *name,
|
||||
int pfs_task_mkdir(psync_fsfolderid_t folderid, const char *name,
|
||||
uint32_t folderflags);
|
||||
int psync_fstask_can_rmdir(psync_fsfolderid_t folderid, uint32_t parentflags,
|
||||
int pfs_task_can_rmdir(psync_fsfolderid_t folderid, uint32_t parentflags,
|
||||
const char *name);
|
||||
int psync_fstask_rmdir(psync_fsfolderid_t folderid, uint32_t parentflags,
|
||||
int pfs_task_rmdir(psync_fsfolderid_t folderid, uint32_t parentflags,
|
||||
const char *name);
|
||||
psync_fstask_creat_t *psync_fstask_add_creat(psync_fstask_folder_t *folder,
|
||||
psync_fstask_creat_t *pfs_task_add_creat(psync_fstask_folder_t *folder,
|
||||
const char *name,
|
||||
psync_fsfileid_t fileid,
|
||||
const char *encsymkey,
|
||||
size_t encsymkeylen);
|
||||
void psync_fstask_inject_creat(psync_fstask_folder_t *folder,
|
||||
void pfs_task_inject_creat(psync_fstask_folder_t *folder,
|
||||
psync_fstask_creat_t *cr);
|
||||
void psync_fstask_inject_unlink(psync_fstask_folder_t *folder,
|
||||
void pfs_task_inject_unlink(psync_fstask_folder_t *folder,
|
||||
psync_fstask_unlink_t *un);
|
||||
psync_fstask_creat_t *
|
||||
psync_fstask_add_modified_file(psync_fstask_folder_t *folder, const char *name,
|
||||
pfs_task_add_modified_file(psync_fstask_folder_t *folder, const char *name,
|
||||
psync_fsfileid_t fileid, uint64_t hash,
|
||||
const char *encsymkey, size_t encsymkeylen);
|
||||
int psync_fstask_set_mtime(psync_fileid_t fileid, uint64_t oldtm,
|
||||
int pfs_task_set_mtime(psync_fileid_t fileid, uint64_t oldtm,
|
||||
uint64_t newtm, int is_ctime);
|
||||
|
||||
int psync_fstask_add_local_creat_static(psync_fsfolderid_t folderid,
|
||||
int pfs_task_add_local_creat_static(psync_fsfolderid_t folderid,
|
||||
const char *name, const void *data,
|
||||
size_t datalen);
|
||||
|
||||
int psync_fstask_can_unlink(psync_fsfolderid_t folderid, const char *name);
|
||||
int psync_fstask_unlink(psync_fsfolderid_t folderid, const char *name);
|
||||
int psync_fstask_rename_file(psync_fsfileid_t fileid,
|
||||
int pfs_task_can_unlink(psync_fsfolderid_t folderid, const char *name);
|
||||
int pfs_task_unlink(psync_fsfolderid_t folderid, const char *name);
|
||||
int pfs_task_rename_file(psync_fsfileid_t fileid,
|
||||
psync_fsfolderid_t parentfolderid,
|
||||
const char *name, psync_fsfolderid_t to_folderid,
|
||||
const char *new_name);
|
||||
int psync_fstask_rename_folder(psync_fsfolderid_t folderid,
|
||||
int pfs_task_rename_folder(psync_fsfolderid_t folderid,
|
||||
psync_fsfolderid_t parentfolderid,
|
||||
const char *name, psync_fsfolderid_t to_folderid,
|
||||
const char *new_name, uint32_t targetflags);
|
||||
|
||||
void psync_fstask_clean();
|
||||
void pfs_task_clean();
|
||||
|
||||
void psync_fstask_add_banned_folders();
|
||||
void pfs_task_add_banned_folders();
|
||||
|
||||
#if IS_DEBUG
|
||||
void psync_fstask_dump_state();
|
||||
void pfs_task_dump_state();
|
||||
#endif
|
||||
|
||||
#endif
|
||||
|
|
|
|||
|
|
@ -155,13 +155,13 @@ static int psync_process_task_mkdir(fsupload_task_t *task) {
|
|||
folderid = papi_find_result2(meta, "folderid", PARAM_NUM)->num;
|
||||
task->int2 = folderid;
|
||||
pfileops_create_fldr(meta);
|
||||
psync_fstask_folder_created(task->folderid, task->id, folderid, task->text1);
|
||||
psync_fs_task_to_folder(task->id, folderid);
|
||||
pfs_task_folder_created(task->folderid, task->id, folderid, task->text1);
|
||||
pfs_xatr_task_to_folder(task->id, folderid);
|
||||
if (task->text2 && papi_find_result2(task->res, "created", PARAM_BOOL)->num) {
|
||||
psync_sql_res *res;
|
||||
unsigned char *enckey;
|
||||
size_t enckeylen;
|
||||
enckey = psync_base64_decode((const unsigned char *)task->text2,
|
||||
enckey = putil_base64_decode((const unsigned char *)task->text2,
|
||||
strlen(task->text2), &enckeylen);
|
||||
if (pdbg_likely(enckey)) {
|
||||
res = psql_prepare(
|
||||
|
|
@ -193,14 +193,14 @@ static int handle_rmdir_api_error(uint64_t result, fsupload_task_t *task) {
|
|||
switch (result) {
|
||||
case 2005: /* folder does not exist, kind of success */
|
||||
// pfileops_delete_fldr(task->sfolderid);
|
||||
psync_fstask_folder_deleted(task->folderid, task->id, task->text1);
|
||||
pfs_task_folder_deleted(task->folderid, task->id, task->text1);
|
||||
return 0;
|
||||
case 2003: /* access denied, skip*/
|
||||
case 2006: /* not empty */
|
||||
case 2028: /* folder is shared */
|
||||
case 2287: /* public folder */
|
||||
case 2345: /* backup */
|
||||
psync_fstask_folder_deleted(task->folderid, task->id, task->text1);
|
||||
pfs_task_folder_deleted(task->folderid, task->id, task->text1);
|
||||
return 0;
|
||||
default:
|
||||
return -1;
|
||||
|
|
@ -214,7 +214,7 @@ static int psync_process_task_rmdir(fsupload_task_t *task) {
|
|||
return handle_rmdir_api_error(result, task);
|
||||
pfileops_delete_fldr(
|
||||
papi_find_result2(task->res, "metadata", PARAM_HASH));
|
||||
psync_fstask_folder_deleted(task->folderid, task->id, task->text1);
|
||||
pfs_task_folder_deleted(task->folderid, task->id, task->text1);
|
||||
pdbg_logf(D_NOTICE, "folder %lu/%s deleted", (unsigned long)task->folderid,
|
||||
task->text1);
|
||||
return 0;
|
||||
|
|
@ -265,7 +265,7 @@ static int psync_send_task_creat_upload_small(psock_t *api,
|
|||
data = papi_prepare_alloc("uploadfile", params, size, size, &len);
|
||||
}
|
||||
if (pdbg_unlikely(pfile_read(fd, data + len, size) != size) ||
|
||||
pdbg_unlikely(psync_fs_get_file_writeid(task->id) != task->int1)) {
|
||||
pdbg_unlikely(pfs_get_file_writeid(task->id) != task->int1)) {
|
||||
free(data);
|
||||
return -1;
|
||||
}
|
||||
|
|
@ -361,14 +361,14 @@ static int handle_upload_api_error_taskid(uint64_t result, uint64_t taskid) {
|
|||
res = psql_prepare("UPDATE fstask SET folderid=0 WHERE id=?");
|
||||
psql_bind_uint(res, 1, taskid);
|
||||
psql_run_free(res);
|
||||
psync_fsupload_wake();
|
||||
pfs_upld_wake();
|
||||
return -1;
|
||||
case 2001: /* invalid filename */
|
||||
res = psql_prepare(
|
||||
"UPDATE fstask SET text1=\"Invalid Name Requested\" WHERE id=?");
|
||||
psql_bind_uint(res, 1, taskid);
|
||||
psql_run_free(res);
|
||||
psync_fsupload_wake();
|
||||
pfs_upld_wake();
|
||||
return -1;
|
||||
case 2008: { /* overquota */
|
||||
int locked = psql_locked();
|
||||
|
|
@ -402,7 +402,7 @@ static void set_key_for_fileid(psync_fileid_t fileid, uint64_t hash,
|
|||
unsigned char *enckey;
|
||||
size_t enckeylen;
|
||||
enckey =
|
||||
psync_base64_decode((const unsigned char *)key, strlen(key), &enckeylen);
|
||||
putil_base64_decode((const unsigned char *)key, strlen(key), &enckeylen);
|
||||
if (pdbg_likely(enckey)) {
|
||||
res = psql_prepare(
|
||||
"REPLACE INTO cryptofilekey (fileid, hash, enckey) VALUES (?, ?, ?)");
|
||||
|
|
@ -429,7 +429,7 @@ static int save_meta(const binresult *meta, psync_folderid_t folderid,
|
|||
size = papi_find_result2(meta, "size", PARAM_NUM)->num;
|
||||
deleted = 0;
|
||||
psql_start();
|
||||
if (psync_fs_update_openfile(
|
||||
if (pfs_update_openfile(
|
||||
taskid, writeid, fileid, hash, size,
|
||||
papi_find_result2(meta, "created", PARAM_NUM)->num)) {
|
||||
sql = psql_query_nolock("SELECT status FROM fstask WHERE id=?");
|
||||
|
|
@ -454,13 +454,13 @@ static int save_meta(const binresult *meta, psync_folderid_t folderid,
|
|||
pfileops_create_file(meta);
|
||||
if (!deleted)
|
||||
ppagecache_creat(taskid, hash, 0);
|
||||
psync_fstask_file_created(folderid, taskid, name, fileid);
|
||||
psync_fs_task_to_file(taskid, fileid);
|
||||
pfs_task_file_created(folderid, taskid, name, fileid);
|
||||
pfs_xatr_task_to_file(taskid, fileid);
|
||||
} else {
|
||||
pfileops_update_file(meta);
|
||||
if (!deleted)
|
||||
ppagecache_modify(taskid, hash, oldhash);
|
||||
psync_fstask_file_modified(folderid, taskid, name, fileid);
|
||||
pfs_task_file_modified(folderid, taskid, name, fileid);
|
||||
}
|
||||
if (key)
|
||||
set_key_for_fileid(fileid, hash, key);
|
||||
|
|
@ -469,7 +469,7 @@ static int save_meta(const binresult *meta, psync_folderid_t folderid,
|
|||
psql_bind_uint(sql, 1, taskid);
|
||||
psql_run_free(sql);
|
||||
if (psql_affected())
|
||||
psync_fsupload_wake();
|
||||
pfs_upld_wake();
|
||||
sql = psql_prepare("DELETE FROM fstaskupload WHERE fstaskid=?");
|
||||
psql_bind_uint(sql, 1, taskid);
|
||||
psql_run_free(sql);
|
||||
|
|
@ -492,7 +492,7 @@ static int save_meta(const binresult *meta, psync_folderid_t folderid,
|
|||
if (!psql_affected()) {
|
||||
pdbg_logf(D_BUG,
|
||||
"upload of %s cancelled due to writeid mismatch, writeid %lu, "
|
||||
"psync_fs_update_openfile should have catched that",
|
||||
"pfs_update_openfile should have catched that",
|
||||
name, (long unsigned)writeid);
|
||||
psql_rollback();
|
||||
return -1;
|
||||
|
|
@ -590,14 +590,14 @@ static void perm_fail_upload_task(uint64_t taskid) {
|
|||
psql_bind_uint(sql, 1, taskid);
|
||||
psql_run_free(sql);
|
||||
if (psql_affected())
|
||||
psync_fsupload_wake();
|
||||
pfs_upld_wake();
|
||||
sql = psql_prepare("DELETE FROM fstask WHERE fileid=?");
|
||||
psql_bind_int(sql, 1, -(psync_fsfileid_t)taskid);
|
||||
psql_run_free(sql);
|
||||
sql = psql_prepare("DELETE FROM fstask WHERE id=?");
|
||||
psql_bind_uint(sql, 1, taskid);
|
||||
psql_run_free(sql);
|
||||
psync_fs_task_deleted(taskid);
|
||||
pfs_xatr_task_deleted(taskid);
|
||||
psql_commit();
|
||||
pstatus_upload_recalc_async();
|
||||
}
|
||||
|
|
@ -844,7 +844,7 @@ static int large_upload_creat(uint64_t taskid, psync_folderid_t folderid,
|
|||
psync_apipool_release(api);
|
||||
goto errs;
|
||||
}
|
||||
if (psync_fs_get_file_writeid(taskid) != writeid) {
|
||||
if (pfs_get_file_writeid(taskid) != writeid) {
|
||||
pdbg_logf(D_NOTICE, "%s changed while uploading as %lu/%s", filename,
|
||||
(unsigned long)folderid, name);
|
||||
psync_apipool_release(api);
|
||||
|
|
@ -1000,7 +1000,7 @@ int upload_modify(uint64_t taskid, psync_folderid_t folderid, const char *name,
|
|||
}
|
||||
tree = NULL;
|
||||
if (pdbg_unlikely((fsize = pfile_size(fd)) == -1 ||
|
||||
psync_fs_load_interval_tree(fd, fsize, &tree) == -1)) {
|
||||
pfs_load_interval_tree(fd, fsize, &tree) == -1)) {
|
||||
psync_interval_tree_free(tree);
|
||||
pfile_close(fd);
|
||||
return -1;
|
||||
|
|
@ -1110,7 +1110,7 @@ int upload_modify(uint64_t taskid, psync_folderid_t folderid, const char *name,
|
|||
}
|
||||
psync_interval_tree_free(tree);
|
||||
pupload_bytes_sub(asize);
|
||||
if (psync_fs_get_file_writeid(taskid) != writeid) {
|
||||
if (pfs_get_file_writeid(taskid) != writeid) {
|
||||
pdbg_logf(D_NOTICE, "%s changed while uploading as %lu/%s", filename,
|
||||
(unsigned long)folderid, name);
|
||||
psync_apipool_release(api);
|
||||
|
|
@ -1181,9 +1181,9 @@ static void large_upload() {
|
|||
fileidhex[sizeof(psync_fsfileid_t)] = 'd';
|
||||
fileidhex[sizeof(psync_fsfileid_t) + 1] = 0;
|
||||
cname = psync_setting_get_string(_PS(fscachepath));
|
||||
filename = psync_strcat(cname, "/", fileidhex, NULL);
|
||||
filename = putil_strcat(cname, "/", fileidhex, NULL);
|
||||
fileidhex[sizeof(psync_fsfileid_t)] = 'i';
|
||||
indexname = psync_strcat(cname, "/", fileidhex, NULL);
|
||||
indexname = putil_strcat(cname, "/", fileidhex, NULL);
|
||||
res = psql_query_rdlock("SELECT uploadid FROM fstaskupload WHERE "
|
||||
"fstaskid=? ORDER BY uploadid DESC LIMIT 1");
|
||||
psql_bind_uint(res, 1, taskid);
|
||||
|
|
@ -1220,7 +1220,7 @@ static void large_upload() {
|
|||
current_upload_taskid = 0;
|
||||
psql_free(res);
|
||||
if (uploadid != 2)
|
||||
psync_fsupload_wake();
|
||||
pfs_upld_wake();
|
||||
psys_sleep_milliseconds(PSYNC_SLEEP_ON_FAILED_UPLOAD);
|
||||
}
|
||||
free(indexname);
|
||||
|
|
@ -1236,7 +1236,7 @@ static int psync_sent_task_creat_upload_large(fsupload_task_t *task) {
|
|||
res = psql_prepare(
|
||||
"UPDATE fstask SET status=2 WHERE id=? AND status=0");
|
||||
psql_bind_uint(res, 1, task->id);
|
||||
// psync_fs_uploading_openfile(task->id);
|
||||
// pfs_uploading_openfile(task->id);
|
||||
if (!large_upload_running) {
|
||||
large_upload_running = 1;
|
||||
prun_thread("large file fs upload", large_upload);
|
||||
|
|
@ -1245,7 +1245,7 @@ static int psync_sent_task_creat_upload_large(fsupload_task_t *task) {
|
|||
return 0;
|
||||
}
|
||||
|
||||
void psync_fsupload_stop_upload_locked(uint64_t taskid) {
|
||||
void pfs_upld_stop_upload_locked(uint64_t taskid) {
|
||||
psync_sql_res *res;
|
||||
if (current_upload_taskid == taskid)
|
||||
stop_current_upload = 1;
|
||||
|
|
@ -1255,7 +1255,7 @@ void psync_fsupload_stop_upload_locked(uint64_t taskid) {
|
|||
pdbg_assertw(psql_affected());
|
||||
}
|
||||
|
||||
int psync_fsupload_in_current_small_uploads_batch_locked(uint64_t taskid) {
|
||||
int pfs_upld_in_current_small_uploads_batch_locked(uint64_t taskid) {
|
||||
fsupload_task_t *task;
|
||||
if (!current_upload_batch)
|
||||
return 0;
|
||||
|
|
@ -1269,7 +1269,7 @@ int psync_fsupload_in_current_small_uploads_batch_locked(uint64_t taskid) {
|
|||
psync_binhex(fileidhex, &task->id, sizeof(psync_fsfileid_t));
|
||||
fileidhex[sizeof(psync_fsfileid_t)] = 'd';
|
||||
fileidhex[sizeof(psync_fsfileid_t) + 1] = 0;
|
||||
filename = psync_strcat(psync_setting_get_string(_PS(fscachepath)),
|
||||
filename = putil_strcat(psync_setting_get_string(_PS(fscachepath)),
|
||||
"/", fileidhex, NULL);
|
||||
stret = stat(filename, &st);
|
||||
if (stret)
|
||||
|
|
@ -1296,7 +1296,7 @@ static int psync_send_task_creat(psock_t *api, fsupload_task_t *task) {
|
|||
psync_binhex(fileidhex, &task->id, sizeof(psync_fsfileid_t));
|
||||
fileidhex[sizeof(psync_fsfileid_t)] = 'd';
|
||||
fileidhex[sizeof(psync_fsfileid_t) + 1] = 0;
|
||||
filename = psync_strcat(psync_setting_get_string(_PS(fscachepath)),
|
||||
filename = putil_strcat(psync_setting_get_string(_PS(fscachepath)),
|
||||
"/", fileidhex, NULL);
|
||||
fd = pfile_open(filename, O_RDONLY, 0);
|
||||
free(filename);
|
||||
|
|
@ -1345,7 +1345,7 @@ static int psync_process_task_creat(fsupload_task_t *task) {
|
|||
meta = papi_find_result2(task->res, "metadata", PARAM_ARRAY)->array[0];
|
||||
fileid = papi_find_result2(meta, "fileid", PARAM_NUM)->num;
|
||||
hash = papi_find_result2(meta, "hash", PARAM_NUM)->num;
|
||||
if (psync_fs_update_openfile(
|
||||
if (pfs_update_openfile(
|
||||
task->id, task->int1, fileid, hash,
|
||||
papi_find_result2(meta, "size", PARAM_NUM)->num,
|
||||
papi_find_result2(meta, "created", PARAM_NUM)->num)) {
|
||||
|
|
@ -1354,10 +1354,10 @@ static int psync_process_task_creat(fsupload_task_t *task) {
|
|||
return -1;
|
||||
}
|
||||
pfileops_create_file(meta);
|
||||
psync_fstask_file_created(task->folderid, task->id, task->text1, fileid);
|
||||
pfs_task_file_created(task->folderid, task->id, task->text1, fileid);
|
||||
if (task->text2)
|
||||
set_key_for_fileid(fileid, hash, task->text2);
|
||||
psync_fs_task_to_file(task->id, fileid);
|
||||
pfs_xatr_task_to_file(task->id, fileid);
|
||||
task->int2 = fileid;
|
||||
pdbg_logf(D_NOTICE, "file %lu/%s uploaded", (unsigned long)task->folderid,
|
||||
task->text1);
|
||||
|
|
@ -1436,10 +1436,10 @@ static int handle_unlink_api_error(uint64_t result, fsupload_task_t *task) {
|
|||
switch (result) {
|
||||
case 2009: /* file does not exist, kind of success */
|
||||
// pfileops_delete_file(task->fileid);
|
||||
psync_fstask_file_deleted(task->folderid, task->id, task->text1);
|
||||
pfs_task_file_deleted(task->folderid, task->id, task->text1);
|
||||
return 0;
|
||||
case 2003: /* access denied, skip*/
|
||||
psync_fstask_file_deleted(task->folderid, task->id, task->text1);
|
||||
pfs_task_file_deleted(task->folderid, task->id, task->text1);
|
||||
return 0;
|
||||
default:
|
||||
return -1;
|
||||
|
|
@ -1453,7 +1453,7 @@ static int psync_process_task_unlink(fsupload_task_t *task) {
|
|||
return handle_unlink_api_error(result, task);
|
||||
pfileops_delete_file(
|
||||
papi_find_result2(task->res, "metadata", PARAM_HASH));
|
||||
psync_fstask_file_deleted(task->folderid, task->id, task->text1);
|
||||
pfs_task_file_deleted(task->folderid, task->id, task->text1);
|
||||
pdbg_logf(D_NOTICE, "file %lu/%s deleted", (unsigned long)task->folderid,
|
||||
task->text1);
|
||||
return 0;
|
||||
|
|
@ -1559,7 +1559,7 @@ static int handle_rename_file_api_error(uint64_t result,
|
|||
case 2284: /* public folder can't contain download */
|
||||
case 2343: /* backup folders can't contain download links */
|
||||
case 2346: /* you can't place this item in backup folders */
|
||||
psync_fstask_file_renamed(task->folderid, task->id, task->text1,
|
||||
pfs_task_file_renamed(task->folderid, task->id, task->text1,
|
||||
task->int1);
|
||||
return 0;
|
||||
}
|
||||
|
|
@ -1574,7 +1574,7 @@ static int psync_process_task_rename_file(fsupload_task_t *task) {
|
|||
return handle_rename_file_api_error(result, task);
|
||||
meta = papi_find_result2(task->res, "metadata", PARAM_HASH);
|
||||
pfileops_update_file(meta);
|
||||
psync_fstask_file_renamed(task->folderid, task->id, task->text1, task->int1);
|
||||
pfs_task_file_renamed(task->folderid, task->id, task->text1, task->int1);
|
||||
pdbg_logf(D_NOTICE, "file %lu/%s renamed", (unsigned long)task->folderid,
|
||||
task->text1);
|
||||
return 0;
|
||||
|
|
@ -1594,11 +1594,11 @@ static void change_folder_name(fsupload_task_t *task) {
|
|||
if (et > task->text1 && et[0] == '(' && atol(et + 1) < 20) {
|
||||
nn = malloc(sizeof(char) * (et - task->text1 + 7));
|
||||
memcpy(nn, task->text1, et - task->text1);
|
||||
psync_slprintf(nn + (et - task->text1), 7, " (%d)", atoi(et + 1) + 1);
|
||||
putil_slprintf(nn + (et - task->text1), 7, " (%d)", atoi(et + 1) + 1);
|
||||
}
|
||||
}
|
||||
if (!nn) {
|
||||
nn = psync_strcat(task->text1, "(1)", NULL);
|
||||
nn = putil_strcat(task->text1, "(1)", NULL);
|
||||
}
|
||||
res = psql_prepare("UPDATE fstask SET text1=? WHERE id=?");
|
||||
psql_bind_str(res, 1, nn);
|
||||
|
|
@ -1632,7 +1632,7 @@ static int handle_rename_folder_api_error(uint64_t result,
|
|||
case 2342: /* backup folders can't contain upload links */
|
||||
case 2343: /* backup folders can't contain download links */
|
||||
case 2346: /* you can't place this item in backup folder */
|
||||
psync_fstask_folder_renamed(task->folderid, task->id, task->text1,
|
||||
pfs_task_folder_renamed(task->folderid, task->id, task->text1,
|
||||
task->int1);
|
||||
return 0;
|
||||
case 2004: /* destination folder already exists */
|
||||
|
|
@ -1643,7 +1643,7 @@ static int handle_rename_folder_api_error(uint64_t result,
|
|||
folder than the set limit */
|
||||
pdbg_logf(D_ERROR, "Error 2352. Tried to move too many folders into a sahred "
|
||||
"folder at once.");
|
||||
psync_fstask_folder_renamed(task->folderid, task->id, task->text1,
|
||||
pfs_task_folder_renamed(task->folderid, task->id, task->text1,
|
||||
task->int1);
|
||||
pqevent_queue_eventid(PEVENT_SHARE_RENAME_F);
|
||||
return 0;
|
||||
|
|
@ -1663,7 +1663,7 @@ static int psync_process_task_rename_folder(fsupload_task_t *task) {
|
|||
|
||||
meta = papi_find_result2(task->res, "metadata", PARAM_HASH);
|
||||
pfileops_update_fldr(meta);
|
||||
psync_fstask_folder_renamed(task->folderid, task->id, task->text1,
|
||||
pfs_task_folder_renamed(task->folderid, task->id, task->text1,
|
||||
task->int1);
|
||||
pdbg_logf(D_NOTICE, "folder %lu/%s renamed", (unsigned long)task->folderid,
|
||||
task->text1);
|
||||
|
|
@ -1679,13 +1679,13 @@ static void psync_delete_write_cache_file(uint64_t taskid, int index) {
|
|||
fileidhex[sizeof(psync_fsfileid_t) + 1] = 0;
|
||||
cachepath = psync_setting_get_string(_PS(fscachepath));
|
||||
filename =
|
||||
psync_strcat(cachepath, "/", fileidhex, NULL);
|
||||
putil_strcat(cachepath, "/", fileidhex, NULL);
|
||||
pdbg_assertw(pfile_delete(filename) == 0);
|
||||
free(filename);
|
||||
if (index) {
|
||||
fileidhex[sizeof(psync_fsfileid_t)] = 'i';
|
||||
filename =
|
||||
psync_strcat(cachepath, "/", fileidhex, NULL);
|
||||
putil_strcat(cachepath, "/", fileidhex, NULL);
|
||||
pdbg_assertw(pfile_delete(filename) == 0);
|
||||
free(filename);
|
||||
}
|
||||
|
|
@ -1696,7 +1696,7 @@ static int psync_cancel_task_creat(fsupload_task_t *task) {
|
|||
psync_uint_row row;
|
||||
psync_fileid_t fileid;
|
||||
psync_delete_write_cache_file(task->id, 0);
|
||||
psync_fstask_file_created(task->folderid, task->id, task->text1, 0);
|
||||
pfs_task_file_created(task->folderid, task->id, task->text1, 0);
|
||||
res = psql_query_rdlock(
|
||||
"SELECT fileid FROM fstaskfileid WHERE fstaskid=?");
|
||||
psql_bind_uint(res, 1, task->id);
|
||||
|
|
@ -1718,7 +1718,7 @@ static int psync_cancel_task_creat(fsupload_task_t *task) {
|
|||
}
|
||||
|
||||
static int psync_cancel_task_rename_file(fsupload_task_t *task) {
|
||||
psync_fstask_file_renamed(task->folderid, task->id, task->text1, task->int1);
|
||||
pfs_task_file_renamed(task->folderid, task->id, task->text1, task->int1);
|
||||
pdbg_logf(D_NOTICE, "cancelled rename task %lu (from task %lu) for file %s",
|
||||
(unsigned long)task->id, (unsigned long)task->int1, task->text1);
|
||||
return 0;
|
||||
|
|
@ -1727,7 +1727,7 @@ static int psync_cancel_task_rename_file(fsupload_task_t *task) {
|
|||
static int psync_cancel_task_modify(fsupload_task_t *task) {
|
||||
psync_sql_res *res;
|
||||
psync_delete_write_cache_file(task->id, 1);
|
||||
psync_fstask_file_modified(task->folderid, task->id, task->text1, 0);
|
||||
pfs_task_file_modified(task->folderid, task->id, task->text1, 0);
|
||||
res = psql_prepare("UPDATE fstask SET fileid=? WHERE fileid=?");
|
||||
psql_bind_uint(res, 1, task->fileid);
|
||||
psql_bind_int(res, 2, -(psync_fsfileid_t)task->id);
|
||||
|
|
@ -1760,7 +1760,7 @@ static int psync_cancel_task_unlink(fsupload_task_t *task) {
|
|||
psql_run_free(res);
|
||||
return -1;
|
||||
}
|
||||
psync_fstask_file_deleted(task->folderid, task->id, task->text1);
|
||||
pfs_task_file_deleted(task->folderid, task->id, task->text1);
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
|
@ -1779,7 +1779,7 @@ static int psync_cancel_task_unlink_set_rev(fsupload_task_t *task) {
|
|||
psql_run_free(res);
|
||||
return -1;
|
||||
}
|
||||
psync_fstask_file_deleted(task->folderid, task->id, task->text1);
|
||||
pfs_task_file_deleted(task->folderid, task->id, task->text1);
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
|
@ -1885,7 +1885,7 @@ static void pr_update_fileid(psync_fileid_t newfileid,
|
|||
psql_run_free(res);
|
||||
}
|
||||
|
||||
static void psync_fsupload_process_tasks(psync_list *tasks) {
|
||||
static void pfs_upld_process_tasks(psync_list *tasks) {
|
||||
fsupload_task_t *task;
|
||||
uint32_t creats, cancels, dels;
|
||||
creats = 0;
|
||||
|
|
@ -1937,7 +1937,7 @@ static void psync_fsupload_process_tasks(psync_list *tasks) {
|
|||
pdiff_wake();
|
||||
}
|
||||
|
||||
static void psync_fsupload_run_tasks(psync_list *tasks) {
|
||||
static void pfs_upld_run_tasks(psync_list *tasks) {
|
||||
async_result_reader reader;
|
||||
psock_t *api;
|
||||
fsupload_task_t *task, *rtask;
|
||||
|
|
@ -1988,7 +1988,7 @@ static void psync_fsupload_run_tasks(psync_list *tasks) {
|
|||
}
|
||||
psync_apipool_release(api);
|
||||
papi_rdr_free(&reader);
|
||||
psync_fsupload_process_tasks(tasks);
|
||||
pfs_upld_process_tasks(tasks);
|
||||
if (np) {
|
||||
psql_start();
|
||||
psync_list_for_each_element(task, tasks, fsupload_task_t,
|
||||
|
|
@ -2000,7 +2000,7 @@ static void psync_fsupload_run_tasks(psync_list *tasks) {
|
|||
return;
|
||||
err0:
|
||||
psync_apipool_release_bad(api);
|
||||
psync_fsupload_process_tasks(tasks);
|
||||
pfs_upld_process_tasks(tasks);
|
||||
err:
|
||||
papi_rdr_free(&reader);
|
||||
ptimer_notify_exception();
|
||||
|
|
@ -2027,12 +2027,12 @@ static void clean_stuck_tasks() {
|
|||
fileidhex[sizeof(psync_fsfileid_t)] = 'd';
|
||||
fileidhex[sizeof(psync_fsfileid_t) + 1] = 0;
|
||||
filename =
|
||||
psync_strcat(cachepath, "/", fileidhex, NULL);
|
||||
putil_strcat(cachepath, "/", fileidhex, NULL);
|
||||
pfile_delete(filename);
|
||||
free(filename);
|
||||
fileidhex[sizeof(psync_fsfileid_t)] = 'i';
|
||||
filename =
|
||||
psync_strcat(cachepath, "/", fileidhex, NULL);
|
||||
putil_strcat(cachepath, "/", fileidhex, NULL);
|
||||
pfile_delete(filename);
|
||||
free(filename);
|
||||
psql_start();
|
||||
|
|
@ -2048,7 +2048,7 @@ static void clean_stuck_tasks() {
|
|||
free(fr);
|
||||
}
|
||||
|
||||
static void psync_fsupload_check_tasks() {
|
||||
static void pfs_upld_check_tasks() {
|
||||
fsupload_task_t *task;
|
||||
psync_sql_res *res;
|
||||
psync_variant_row row;
|
||||
|
|
@ -2112,14 +2112,14 @@ static void psync_fsupload_check_tasks() {
|
|||
if (cnt == PSYNC_FSUPLOAD_NUM_TASKS_PER_RUN)
|
||||
upload_wakes++;
|
||||
if (!psync_list_isempty(&tasks))
|
||||
psync_fsupload_run_tasks(&tasks);
|
||||
pfs_upld_run_tasks(&tasks);
|
||||
psql_lock();
|
||||
current_upload_batch = NULL;
|
||||
psql_unlock();
|
||||
psync_list_for_each_element_call(&tasks, fsupload_task_t, list, free);
|
||||
}
|
||||
|
||||
static void psync_fsupload_thread() {
|
||||
static void pfs_upld_thread() {
|
||||
int waited;
|
||||
clean_stuck_tasks();
|
||||
waited = 0;
|
||||
|
|
@ -2129,7 +2129,7 @@ static void psync_fsupload_thread() {
|
|||
// it is better to sleep a bit to give a chance for events to accumulate
|
||||
if (waited)
|
||||
psys_sleep_milliseconds(100);
|
||||
psync_fsupload_check_tasks();
|
||||
pfs_upld_check_tasks();
|
||||
pthread_mutex_lock(&upload_mutex);
|
||||
while (!upload_wakes) {
|
||||
pthread_cond_wait(&upload_cond, &upload_mutex);
|
||||
|
|
@ -2140,13 +2140,13 @@ static void psync_fsupload_thread() {
|
|||
}
|
||||
}
|
||||
|
||||
void psync_fsupload_init() {
|
||||
pfscrypto_check_logs();
|
||||
ptimer_exception_handler(psync_fsupload_wake);
|
||||
prun_thread("fsupload main", psync_fsupload_thread);
|
||||
void pfs_upld_init() {
|
||||
pfs_crpt_check_logs();
|
||||
ptimer_exception_handler(pfs_upld_wake);
|
||||
prun_thread("fsupload main", pfs_upld_thread);
|
||||
}
|
||||
|
||||
void psync_fsupload_wake() {
|
||||
void pfs_upld_wake() {
|
||||
pthread_mutex_lock(&upload_mutex);
|
||||
if (!upload_wakes++)
|
||||
pthread_cond_signal(&upload_cond);
|
||||
|
|
|
|||
|
|
@ -34,9 +34,9 @@
|
|||
|
||||
#include <stdint.h>
|
||||
|
||||
void psync_fsupload_init();
|
||||
void psync_fsupload_wake();
|
||||
void psync_fsupload_stop_upload_locked(uint64_t taskid);
|
||||
int psync_fsupload_in_current_small_uploads_batch_locked(uint64_t taskid);
|
||||
void pfs_upld_init();
|
||||
void pfs_upld_wake();
|
||||
void pfs_upld_stop_upload_locked(uint64_t taskid);
|
||||
int pfs_upld_in_current_small_uploads_batch_locked(uint64_t taskid);
|
||||
|
||||
#endif
|
||||
|
|
|
|||
|
|
@ -41,16 +41,16 @@
|
|||
#include "psql.h"
|
||||
#include "plibs.h"
|
||||
|
||||
// needed by psync_fs_set_thread_name
|
||||
// needed by pfs_xatr_set_thread_name
|
||||
extern PSYNC_THREAD const char *psync_thread_name;
|
||||
|
||||
#if IS_DEBUG
|
||||
#define psync_fs_set_thread_name() \
|
||||
#define pfs_xatr_set_thread_name() \
|
||||
do { \
|
||||
psync_thread_name = __FUNCTION__; \
|
||||
} while (0)
|
||||
#else
|
||||
#define psync_fs_set_thread_name() \
|
||||
#define pfs_xatr_set_thread_name() \
|
||||
do { \
|
||||
} while (0)
|
||||
#endif
|
||||
|
|
@ -90,15 +90,15 @@ static void delete_object_id(uint64_t oid) {
|
|||
psql_run_free(res);
|
||||
}
|
||||
|
||||
void psync_fs_file_deleted(psync_fileid_t fileid) {
|
||||
void pfs_xatr_file_deleted(psync_fileid_t fileid) {
|
||||
delete_object_id(fileid_to_objid(fileid));
|
||||
}
|
||||
|
||||
void psync_fs_folder_deleted(psync_folderid_t folderid) {
|
||||
void pfs_xatr_folder_deleted(psync_folderid_t folderid) {
|
||||
delete_object_id(folderid_to_objid(folderid));
|
||||
}
|
||||
|
||||
void psync_fs_task_deleted(uint64_t taskid) {
|
||||
void pfs_xatr_task_deleted(uint64_t taskid) {
|
||||
delete_object_id(taskid_to_objid(taskid));
|
||||
}
|
||||
|
||||
|
|
@ -111,20 +111,20 @@ static void update_object_id(uint64_t ooid, uint64_t noid) {
|
|||
psql_run_free(res);
|
||||
}
|
||||
|
||||
void psync_fs_task_to_file(uint64_t taskid, psync_fileid_t fileid) {
|
||||
void pfs_xatr_task_to_file(uint64_t taskid, psync_fileid_t fileid) {
|
||||
update_object_id(taskid_to_objid(taskid), fileid_to_objid(fileid));
|
||||
}
|
||||
|
||||
void psync_fs_task_to_folder(uint64_t taskid, psync_folderid_t folderid) {
|
||||
void pfs_xatr_task_to_folder(uint64_t taskid, psync_folderid_t folderid) {
|
||||
update_object_id(taskid_to_objid(taskid), folderid_to_objid(folderid));
|
||||
}
|
||||
|
||||
void psync_fs_static_to_task(uint64_t statictaskid, uint64_t taskid) {
|
||||
void pfs_xatr_static_to_task(uint64_t statictaskid, uint64_t taskid) {
|
||||
update_object_id(static_taskid_to_objid(statictaskid),
|
||||
taskid_to_objid(taskid));
|
||||
}
|
||||
|
||||
void psync_fs_file_to_task(psync_fileid_t fileid, uint64_t taskid) {
|
||||
void pfs_xatr_file_to_task(psync_fileid_t fileid, uint64_t taskid) {
|
||||
update_object_id(fileid_to_objid(fileid), taskid_to_objid(taskid));
|
||||
}
|
||||
|
||||
|
|
@ -139,16 +139,16 @@ static int64_t xattr_get_object_id_locked(const char *path) {
|
|||
int checkfile, checkfolder;
|
||||
if (path[1] == 0 && path[0] == '/')
|
||||
return 0;
|
||||
fspath = psync_fsfolder_resolve_path(path);
|
||||
fspath = pfs_fldr_resolve_path(path);
|
||||
if (!fspath) {
|
||||
pdbg_logf(D_NOTICE, "path component of %s not found", path);
|
||||
return -1;
|
||||
}
|
||||
checkfile = 1;
|
||||
checkfolder = 1;
|
||||
folder = psync_fstask_get_folder_tasks_rdlocked(fspath->folderid);
|
||||
folder = pfs_task_get_folder_tasks_rdlocked(fspath->folderid);
|
||||
if (folder) {
|
||||
mk = psync_fstask_find_mkdir(folder, fspath->name, 0);
|
||||
mk = pfs_task_find_mkdir(folder, fspath->name, 0);
|
||||
if (mk) {
|
||||
free(fspath);
|
||||
pdbg_assertw(mk->folderid != 0);
|
||||
|
|
@ -157,7 +157,7 @@ static int64_t xattr_get_object_id_locked(const char *path) {
|
|||
else
|
||||
return taskid_to_objid(-mk->folderid);
|
||||
}
|
||||
cr = psync_fstask_find_creat(folder, fspath->name, 0);
|
||||
cr = pfs_task_find_creat(folder, fspath->name, 0);
|
||||
if (cr) {
|
||||
free(fspath);
|
||||
if (cr->fileid > 0)
|
||||
|
|
@ -185,8 +185,8 @@ static int64_t xattr_get_object_id_locked(const char *path) {
|
|||
return ret;
|
||||
}
|
||||
}
|
||||
checkfolder = !psync_fstask_find_rmdir(folder, fspath->name, 0);
|
||||
checkfile = !psync_fstask_find_unlink(folder, fspath->name, 0);
|
||||
checkfolder = !pfs_task_find_rmdir(folder, fspath->name, 0);
|
||||
checkfile = !pfs_task_find_unlink(folder, fspath->name, 0);
|
||||
}
|
||||
if (fspath->folderid < 0) {
|
||||
free(fspath);
|
||||
|
|
@ -248,12 +248,12 @@ static int64_t xattr_get_object_id_locked(const char *path) {
|
|||
} \
|
||||
} while (0)
|
||||
|
||||
int psync_fs_setxattr(const char *path, const char *name, const char *value,
|
||||
int pfs_xatr_set(const char *path, const char *name, const char *value,
|
||||
size_t size, int flags PFS_XATTR_IGN) {
|
||||
psync_sql_res *res;
|
||||
int64_t oid;
|
||||
int ret;
|
||||
psync_fs_set_thread_name();
|
||||
pfs_xatr_set_thread_name();
|
||||
pdbg_logf(D_NOTICE, "setting attribute %s of %s", name, path);
|
||||
LOCK_AND_LOOKUP();
|
||||
if (flags & XATTR_CREATE) {
|
||||
|
|
@ -291,12 +291,12 @@ int psync_fs_setxattr(const char *path, const char *name, const char *value,
|
|||
return ret;
|
||||
}
|
||||
|
||||
int psync_fs_getxattr(const char *path, const char *name, char *value,
|
||||
int pfs_xatr_get(const char *path, const char *name, char *value,
|
||||
size_t size PFS_XATTR_IGN) {
|
||||
psync_sql_res *res;
|
||||
int64_t oid;
|
||||
int ret;
|
||||
psync_fs_set_thread_name();
|
||||
pfs_xatr_set_thread_name();
|
||||
LOCK_AND_LOOKUPRD();
|
||||
if (size && value) {
|
||||
psync_variant_row row;
|
||||
|
|
@ -341,13 +341,13 @@ int psync_fs_getxattr(const char *path, const char *name, char *value,
|
|||
return ret;
|
||||
}
|
||||
|
||||
int psync_fs_listxattr(const char *path, char *list, size_t size) {
|
||||
int pfs_xatr_list(const char *path, char *list, size_t size) {
|
||||
psync_sql_res *res;
|
||||
int64_t oid;
|
||||
const char *str;
|
||||
size_t len;
|
||||
int ret;
|
||||
psync_fs_set_thread_name();
|
||||
pfs_xatr_set_thread_name();
|
||||
LOCK_AND_LOOKUPRD();
|
||||
if (size && list) {
|
||||
psync_variant_row row;
|
||||
|
|
@ -382,11 +382,11 @@ int psync_fs_listxattr(const char *path, char *list, size_t size) {
|
|||
return ret;
|
||||
}
|
||||
|
||||
int psync_fs_removexattr(const char *path, const char *name) {
|
||||
int pfs_xatr_remove(const char *path, const char *name) {
|
||||
psync_sql_res *res;
|
||||
int64_t oid;
|
||||
uint32_t aff;
|
||||
psync_fs_set_thread_name();
|
||||
pfs_xatr_set_thread_name();
|
||||
LOCK_AND_LOOKUP();
|
||||
res = psql_prepare(
|
||||
"DELETE FROM fsxattr WHERE objectid=? AND name=?");
|
||||
|
|
|
|||
|
|
@ -38,20 +38,20 @@
|
|||
|
||||
#define PFS_XATTR_IGN
|
||||
|
||||
int psync_fs_setxattr(const char *path, const char *name, const char *value,
|
||||
int pfs_xatr_set(const char *path, const char *name, const char *value,
|
||||
size_t size, int flags PFS_XATTR_IGN);
|
||||
int psync_fs_getxattr(const char *path, const char *name, char *value,
|
||||
int pfs_xatr_get(const char *path, const char *name, char *value,
|
||||
size_t size PFS_XATTR_IGN);
|
||||
int psync_fs_listxattr(const char *path, char *list, size_t size);
|
||||
int psync_fs_removexattr(const char *path, const char *name);
|
||||
int pfs_xatr_list(const char *path, char *list, size_t size);
|
||||
int pfs_xatr_remove(const char *path, const char *name);
|
||||
|
||||
void psync_fs_file_deleted(psync_fileid_t fileid);
|
||||
void psync_fs_folder_deleted(psync_folderid_t folderid);
|
||||
void psync_fs_task_deleted(uint64_t taskid);
|
||||
void pfs_xatr_file_deleted(psync_fileid_t fileid);
|
||||
void pfs_xatr_folder_deleted(psync_folderid_t folderid);
|
||||
void pfs_xatr_task_deleted(uint64_t taskid);
|
||||
|
||||
void psync_fs_task_to_file(uint64_t taskid, psync_fileid_t fileid);
|
||||
void psync_fs_task_to_folder(uint64_t taskid, psync_folderid_t folderid);
|
||||
void psync_fs_static_to_task(uint64_t statictaskid, uint64_t taskid);
|
||||
void psync_fs_file_to_task(psync_fileid_t fileid, uint64_t taskid);
|
||||
void pfs_xatr_task_to_file(uint64_t taskid, psync_fileid_t fileid);
|
||||
void pfs_xatr_task_to_folder(uint64_t taskid, psync_folderid_t folderid);
|
||||
void pfs_xatr_static_to_task(uint64_t statictaskid, uint64_t taskid);
|
||||
void pfs_xatr_file_to_task(psync_fileid_t fileid, uint64_t taskid);
|
||||
|
||||
#endif
|
||||
|
|
|
|||
|
|
@ -92,7 +92,7 @@ int psync_rename_conflicted_file(const char *path) {
|
|||
num = 0;
|
||||
while (1) {
|
||||
if (num)
|
||||
l = psync_slprintf(npath + dotidx, 32, " (conflicted %ld)", num);
|
||||
l = putil_slprintf(npath + dotidx, 32, " (conflicted %ld)", num);
|
||||
else {
|
||||
l = 13;
|
||||
memcpy(npath + dotidx, " (conflicted)", l);
|
||||
|
|
|
|||
|
|
@ -91,8 +91,8 @@ extern "C" {
|
|||
&(v))))
|
||||
#define psync_dup_string(v) \
|
||||
(likely((v).type == PSYNC_TSTRING) \
|
||||
? psync_strndup((v).str, (v).length) \
|
||||
: psync_strdup(psql_expect_str(__FILE__, __FUNCTION__, \
|
||||
? putil_strndup((v).str, (v).length) \
|
||||
: putil_strdup(psql_expect_str(__FILE__, __FUNCTION__, \
|
||||
__LINE__, &(v))))
|
||||
#define psync_get_lstring(v, l) \
|
||||
psql_lstring_expected(__FILE__, __FUNCTION__, __LINE__, &(v), l)
|
||||
|
|
@ -165,7 +165,7 @@ static inline void psync_get_string_id(char *dst, const char *prefix, uint64_t i
|
|||
plen = strlen(prefix);
|
||||
dst = (char *)memcpy(dst, prefix, plen) + plen;
|
||||
do {
|
||||
*dst++ = base64_table[id % 64];
|
||||
*dst++ = putil_base64_table[id % 64];
|
||||
id /= 64;
|
||||
} while (id);
|
||||
*dst = 0;
|
||||
|
|
@ -177,12 +177,12 @@ static inline void psync_get_string_id2(char *dst, const char *prefix, uint64_t
|
|||
plen = strlen(prefix);
|
||||
dst = (char *)memcpy(dst, prefix, plen) + plen;
|
||||
do {
|
||||
*dst++ = base64_table[id1 % 64];
|
||||
*dst++ = putil_base64_table[id1 % 64];
|
||||
id1 /= 64;
|
||||
} while (id1);
|
||||
*dst++ = '.';
|
||||
do {
|
||||
*dst++ = base64_table[id2 % 64];
|
||||
*dst++ = putil_base64_table[id2 % 64];
|
||||
id2 /= 64;
|
||||
} while (id2);
|
||||
*dst = 0;
|
||||
|
|
|
|||
|
|
@ -119,7 +119,7 @@ static void add_dir_scan(localnotify_dir *dir, const char *path) {
|
|||
if (de->d_name[0] != '.' ||
|
||||
(de->d_name[1] != 0 &&
|
||||
(de->d_name[1] != '.' || de->d_name[2] != 0))) {
|
||||
psync_strlcpy(cpath + pl, de->d_name, namelen + 1);
|
||||
putil_strlcpy(cpath + pl, de->d_name, namelen + 1);
|
||||
if (!lstat(cpath, &st) && S_ISDIR(st.st_mode))
|
||||
add_dir_scan(dir, cpath);
|
||||
}
|
||||
|
|
@ -222,7 +222,7 @@ static uint32_t process_notification(localnotify_dir *dir) {
|
|||
while (wch) {
|
||||
if (wch->watchid == ev.wd) {
|
||||
wch->path[wch->pathlen] = '/';
|
||||
psync_strlcpy(wch->path + wch->pathlen + 1,
|
||||
putil_strlcpy(wch->path + wch->pathlen + 1,
|
||||
buff + off + offsetof(struct inotify_event, name),
|
||||
wch->namelen + 1);
|
||||
if (!lstat(wch->path, &st) && S_ISDIR(st.st_mode))
|
||||
|
|
|
|||
|
|
@ -143,7 +143,7 @@ static void scanner_set_syncs_to_list(psync_list *lst,
|
|||
|
||||
psync_list_init(lst);
|
||||
psync_list_init(lst_deviceid_full);
|
||||
syncmp = psync_fs_getmountpoint();
|
||||
syncmp = pfs_getmountpoint();
|
||||
res = psql_query_rdlock(
|
||||
"SELECT id, folderid, localpath, synctype, deviceid, inode FROM "
|
||||
"syncfolder WHERE synctype&" NTO_STR(PSYNC_UPLOAD_ONLY) "=" NTO_STR(
|
||||
|
|
@ -438,7 +438,7 @@ static void add_new_element(const sync_folderlist *e, psync_folderid_t folderid,
|
|||
return;
|
||||
if (psync_is_name_to_ignore(e->name))
|
||||
return;
|
||||
if (!psync_is_valid_utf8(e->name)) {
|
||||
if (!putil_is_valid_utf8(e->name)) {
|
||||
pdbg_logf(D_WARNING, "ignoring %s with invalid UTF8 name %s",
|
||||
e->isfolder ? "folder" : "file", e->name);
|
||||
return;
|
||||
|
|
@ -569,7 +569,7 @@ scanner_scan_folder(const char *localpath, psync_folderid_t folderid,
|
|||
psync_list_for_each_element(l, &disklist, sync_folderlist,
|
||||
list) if (l->isfolder && l->localid &&
|
||||
l->deviceid == deviceid) {
|
||||
subpath = psync_strcat(localpath, "/", l->name, NULL);
|
||||
subpath = putil_strcat(localpath, "/", l->name, NULL);
|
||||
scanner_scan_folder(subpath, l->remoteid, l->localid, syncid, synctype,
|
||||
deviceid);
|
||||
free(subpath);
|
||||
|
|
|
|||
|
|
@ -342,7 +342,7 @@ void psync_apipool_release_bad(psock_t *api) { psync_ret_api(api); }
|
|||
|
||||
static void rm_all(void *vpath, ppath_stat *st) {
|
||||
char *path;
|
||||
path = psync_strcat((char *)vpath, "/", st->name, NULL);
|
||||
path = putil_strcat((char *)vpath, "/", st->name, NULL);
|
||||
if (pfile_stat_isfolder(&st->stat)) {
|
||||
ppath_ls(path, rm_all, path);
|
||||
rmdir(path);
|
||||
|
|
@ -355,7 +355,7 @@ static void rm_ign(void *vpath, ppath_stat *st) {
|
|||
char *path;
|
||||
int ign;
|
||||
ign = psync_is_name_to_ignore(st->name);
|
||||
path = psync_strcat((char *)vpath, "/", st->name, NULL);
|
||||
path = putil_strcat((char *)vpath, "/", st->name, NULL);
|
||||
if (pfile_stat_isfolder(&st->stat)) {
|
||||
if (ign)
|
||||
ppath_ls(path, rm_all, path);
|
||||
|
|
@ -984,9 +984,9 @@ cont:
|
|||
*ptr = 0;
|
||||
/* pdbg_logf(D_NOTICE, "key=%s, value=%s", key, val);*/
|
||||
if (!memcmp(key, "content-length", 14))
|
||||
clen = psync_ato64(val);
|
||||
clen = putil_ato64(val);
|
||||
else if (!memcmp(key, "keep-alive", 10) && !memcmp(val, "timeout=", 8))
|
||||
keepalive = psync_ato32(val + 8);
|
||||
keepalive = putil_ato32(val + 8);
|
||||
key = ptr + 1;
|
||||
isval = 0;
|
||||
} else if (ch == ':' && !isval) {
|
||||
|
|
@ -1482,9 +1482,9 @@ cont:
|
|||
*ptr = 0;
|
||||
/* pdbg_logf(D_NOTICE, "key=%s, value=%s", key, val);*/
|
||||
if (!memcmp(key, "content-length", 14))
|
||||
clen = psync_ato64(val);
|
||||
clen = putil_ato64(val);
|
||||
else if (!memcmp(key, "keep-alive", 10) && !memcmp(val, "timeout=", 8))
|
||||
keepalive = psync_ato32(val + 8);
|
||||
keepalive = putil_ato32(val + 8);
|
||||
key = ptr + 1;
|
||||
isval = 0;
|
||||
} else if (ch == ':' && !isval) {
|
||||
|
|
@ -1624,7 +1624,7 @@ static int psync_net_get_checksums(psock_t *api, psync_fileid_t fileid,
|
|||
}
|
||||
hosts = papi_find_result2(res, "hosts", PARAM_ARRAY);
|
||||
requestpath = papi_find_result2(res, "path", PARAM_STR)->str;
|
||||
psync_slprintf(cookie, sizeof(cookie), "Cookie: dwltag=%s\015\012",
|
||||
putil_slprintf(cookie, sizeof(cookie), "Cookie: dwltag=%s\015\012",
|
||||
papi_find_result2(res, "dwltag", PARAM_STR)->str);
|
||||
http = NULL;
|
||||
for (i = 0; i < hosts->length; i++)
|
||||
|
|
@ -2682,13 +2682,13 @@ int psync_do_run_command_res(const char *cmd, size_t cmdlen,
|
|||
if (result) {
|
||||
pdbg_logf(D_WARNING, "command %s returned code %u", cmd, (unsigned)result);
|
||||
if (err)
|
||||
*err = psync_strdup(papi_find_result2(res, "error", PARAM_STR)->str);
|
||||
*err = putil_strdup(papi_find_result2(res, "error", PARAM_STR)->str);
|
||||
psync_process_api_error(result);
|
||||
}
|
||||
free(res);
|
||||
return (int)result;
|
||||
neterr:
|
||||
if (err)
|
||||
*err = psync_strdup("Could not connect to the server.");
|
||||
*err = putil_strdup("Could not connect to the server.");
|
||||
return -1;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -80,12 +80,12 @@ static void psync_notifications_download_thumb(const binresult *thumb,
|
|||
filename = strrchr(path, '/');
|
||||
if (pdbg_unlikely(!filename++))
|
||||
return;
|
||||
filepath = psync_strcat(thumbpath, "/", filename, NULL);
|
||||
filepath = putil_strcat(thumbpath, "/", filename, NULL);
|
||||
if (!stat(filepath, &st)) {
|
||||
pdbg_logf(D_NOTICE, "skipping download of %s as it already exists", filename);
|
||||
goto err0;
|
||||
}
|
||||
tmpfilepath = psync_strcat(filepath, ".part", NULL);
|
||||
tmpfilepath = putil_strcat(filepath, ".part", NULL);
|
||||
pdbg_logf(D_NOTICE, "downloading thumbnail %s", filename);
|
||||
if (pdbg_unlikely((fd = pfile_open(tmpfilepath, O_WRONLY,
|
||||
O_CREAT | O_TRUNC)) ==
|
||||
|
|
@ -95,7 +95,7 @@ static void psync_notifications_download_thumb(const binresult *thumb,
|
|||
papi_find_result2(thumb, "hosts", PARAM_ARRAY), &host);
|
||||
if (pdbg_unlikely(!sock))
|
||||
goto err2;
|
||||
psync_slprintf(cookie, sizeof(cookie), "Cookie: dwltag=%s\015\012",
|
||||
putil_slprintf(cookie, sizeof(cookie), "Cookie: dwltag=%s\015\012",
|
||||
papi_find_result2(thumb, "dwltag", PARAM_STR)->str);
|
||||
if (pdbg_unlikely(psync_http_request(sock, host, path, 0, 0, cookie)))
|
||||
goto err3;
|
||||
|
|
@ -187,7 +187,7 @@ void pnotify_set_callback(
|
|||
pthread_mutex_lock(&ntf_mutex);
|
||||
ts = ntf_thumb_size;
|
||||
if (thumbsize)
|
||||
ntf_thumb_size = psync_strdup(thumbsize);
|
||||
ntf_thumb_size = putil_strdup(thumbsize);
|
||||
else
|
||||
ntf_thumb_size = NULL;
|
||||
if (ts)
|
||||
|
|
@ -326,7 +326,7 @@ psync_notification_list_t *pnotify_get() {
|
|||
filename = strrchr(papi_find_result2(br, "path", PARAM_STR)->str, '/');
|
||||
if (filename++) {
|
||||
psync_notification_remove_from_list(&thumbs, filename);
|
||||
filepath = psync_strcat(thumbpath, "/",
|
||||
filepath = putil_strcat(thumbpath, "/",
|
||||
filename, NULL);
|
||||
if (!stat(filepath, &st)) {
|
||||
pntf->thumb = filepath;
|
||||
|
|
@ -355,7 +355,7 @@ psync_notification_list_t *pnotify_get() {
|
|||
nx = ptree_get_next_safe(thumbs);
|
||||
pdbg_logf(D_NOTICE, "deleting unused thumb %s",
|
||||
ptree_element(thumbs, psync_thumb_list_t, tree)->name);
|
||||
filepath = psync_strcat(
|
||||
filepath = putil_strcat(
|
||||
thumbpath, "/",
|
||||
ptree_element(thumbs, psync_thumb_list_t, tree)->name, NULL);
|
||||
pfile_delete(filepath);
|
||||
|
|
|
|||
|
|
@ -526,7 +526,7 @@ static void set_urls(psync_urls_t *urls, binresult *res) {
|
|||
}
|
||||
|
||||
static void psync_pagecache_set_bad_encoder(psync_openfile_t *of) {
|
||||
psync_fs_lock_file(of);
|
||||
pfs_lock_file(of);
|
||||
if (likely(of->encoder == PSYNC_CRYPTO_LOADING_SECTOR_ENCODER)) {
|
||||
of->encoder = PSYNC_CRYPTO_FAILED_SECTOR_ENCODER;
|
||||
pthread_cond_broadcast(&enc_key_cond);
|
||||
|
|
@ -618,7 +618,7 @@ static int get_urls(psync_request_t *request, psync_urls_t *urls) {
|
|||
goto err4;
|
||||
pdbg_logf(D_BUG, "got key for fileid %lu", (unsigned long)request->fileid);
|
||||
free(ret);
|
||||
psync_fs_lock_file(request->of);
|
||||
pfs_lock_file(request->of);
|
||||
if (pdbg_likely(request->of->encoder ==
|
||||
PSYNC_CRYPTO_LOADING_SECTOR_ENCODER)) {
|
||||
request->of->encoder = enc;
|
||||
|
|
@ -2171,7 +2171,7 @@ int ppagecache_read_mod_locked(psync_openfile_t *of, char *buf,
|
|||
rd = ppagecache_read_unmod_locked(of, buf, size, offset);
|
||||
if (rd < 0)
|
||||
return rd;
|
||||
psync_fs_lock_file(of);
|
||||
pfs_lock_file(of);
|
||||
fi = psync_interval_tree_first_interval_containing_or_after(
|
||||
of->writeintervals, offset);
|
||||
if (!fi || fi->from >= offset + size) {
|
||||
|
|
@ -2266,7 +2266,7 @@ static void psync_pagecache_send_error(psync_request_t *request, int err) {
|
|||
unlock_wait(request->ash);
|
||||
if (request->needkey)
|
||||
psync_pagecache_set_bad_encoder(request->of);
|
||||
psync_fs_dec_of_refcnt_and_readers(request->of);
|
||||
pfs_dec_of_refcnt_and_readers(request->of);
|
||||
psync_pagecache_free_request(request);
|
||||
}
|
||||
|
||||
|
|
@ -2384,7 +2384,7 @@ char *psync_http_construct_range_next_header(psync_request_t *request,
|
|||
}
|
||||
if (off < sizeof(PSYNC_CONSTRUCT_HEADER))
|
||||
return NULL;
|
||||
return psync_strdup((char *)memcpy(
|
||||
return putil_strdup((char *)memcpy(
|
||||
buff + off - sizeof(PSYNC_CONSTRUCT_HEADER) + 3, PSYNC_CONSTRUCT_HEADER,
|
||||
sizeof(PSYNC_CONSTRUCT_HEADER) - 1));
|
||||
}
|
||||
|
|
@ -2422,7 +2422,7 @@ retry:
|
|||
psync_pagecache_send_error(request, -EIO);
|
||||
return;
|
||||
}
|
||||
psync_fs_lock_file(request->of);
|
||||
pfs_lock_file(request->of);
|
||||
if (pdbg_likely(request->of->encoder ==
|
||||
PSYNC_CRYPTO_LOADING_SECTOR_ENCODER)) {
|
||||
request->of->encoder = enc;
|
||||
|
|
@ -2435,12 +2435,12 @@ retry:
|
|||
}
|
||||
if (psync_list_isempty(&request->ranges)) {
|
||||
release_urls(urls);
|
||||
psync_fs_dec_of_refcnt_and_readers(request->of);
|
||||
pfs_dec_of_refcnt_and_readers(request->of);
|
||||
psync_pagecache_free_request(request);
|
||||
return;
|
||||
}
|
||||
hosts = papi_find_result2(urls->urls, "hosts", PARAM_ARRAY);
|
||||
psync_slprintf(cookie, sizeof(cookie), "Cookie: dwltag=%s\015\012",
|
||||
putil_slprintf(cookie, sizeof(cookie), "Cookie: dwltag=%s\015\012",
|
||||
papi_find_result2(urls->urls, "dwltag", PARAM_STR)->str);
|
||||
sock = psync_http_connect_multihost_from_cache(hosts, &host);
|
||||
if (!sock) {
|
||||
|
|
@ -2571,7 +2571,7 @@ retry:
|
|||
psync_http_close(sock);
|
||||
pdbg_logf(D_NOTICE, "request from %s finished", host);
|
||||
ok1:
|
||||
psync_fs_dec_of_refcnt_and_readers(request->of);
|
||||
pfs_dec_of_refcnt_and_readers(request->of);
|
||||
psync_pagecache_free_request(request);
|
||||
release_urls(urls);
|
||||
return;
|
||||
|
|
@ -2740,7 +2740,7 @@ static void psync_pagecache_read_unmodified_readahead(
|
|||
uint32_t asize, aoff;
|
||||
for (i = 0; i < pagecnt; i += PSYNC_CRYPTO_HASH_TREE_SECTORS) {
|
||||
for (l = 0; l < offsets->treelevels; l++) {
|
||||
pfscrypto_get_auth_off(first_page_id + i, l, offsets,
|
||||
pfs_crpt_get_auth_off(first_page_id + i, l, offsets,
|
||||
&aoffset, &asize, &aoff);
|
||||
pageid = aoffset / PSYNC_FS_PAGE_SIZE;
|
||||
check_or_request_page(fileid, hash, pageid, ranges);
|
||||
|
|
@ -2750,8 +2750,8 @@ static void psync_pagecache_read_unmodified_readahead(
|
|||
}
|
||||
}
|
||||
// this may include some auth sectors, but should do no harm
|
||||
rto = pfscrypto_sector_id(first_page_id + pagecnt);
|
||||
first_page_id = pfscrypto_sector_id(first_page_id);
|
||||
rto = pfs_crpt_sector_id(first_page_id + pagecnt);
|
||||
first_page_id = pfs_crpt_sector_id(first_page_id);
|
||||
pagecnt = rto - first_page_id;
|
||||
}
|
||||
pages_in_db = has_pages_in_db(hash, first_page_id, pagecnt, 1);
|
||||
|
|
@ -2950,7 +2950,7 @@ int ppagecache_read_unmod_locked(psync_openfile_t *of, char *buf,
|
|||
rq->fileid = fileid;
|
||||
rq->hash = hash;
|
||||
rq->needkey = 0;
|
||||
psync_fs_inc_of_refcnt_and_readers(of);
|
||||
pfs_inc_of_refcnt_and_readers(of);
|
||||
prun_thread1("read unmodified", psync_pagecache_read_unmodified_thread,
|
||||
rq);
|
||||
} else
|
||||
|
|
@ -3097,7 +3097,7 @@ int ppagecache_read_unmod_enc_locked(psync_openfile_t *of,
|
|||
needkey = 0;
|
||||
pthread_mutex_unlock(&of->mutex);
|
||||
pdbg_assert(PSYNC_CRYPTO_SECTOR_SIZE == PSYNC_FS_PAGE_SIZE);
|
||||
pfscrypto_offset_by_size(initialsize, &offsets);
|
||||
pfs_crpt_offset_by_size(initialsize, &offsets);
|
||||
if (offset >= initialsize)
|
||||
return 0;
|
||||
if (offset + size > initialsize)
|
||||
|
|
@ -3121,7 +3121,7 @@ int ppagecache_read_unmod_enc_locked(psync_openfile_t *of,
|
|||
dp[i].authpage = ap;
|
||||
continue;
|
||||
}
|
||||
pfscrypto_get_auth_off(first_page_id + i, 0, &offsets,
|
||||
pfs_crpt_get_auth_off(first_page_id + i, 0, &offsets,
|
||||
&aoffset, &asize, &aoff);
|
||||
ap = malloc(sizeof(psync_crypto_auth_page));
|
||||
ap->waiter = NULL;
|
||||
|
|
@ -3141,7 +3141,7 @@ int ppagecache_read_unmod_enc_locked(psync_openfile_t *of,
|
|||
unsigned long l;
|
||||
lap = ap;
|
||||
for (l = 1; l <= offsets.treelevels; l++) {
|
||||
pfscrypto_get_auth_off(first_page_id + i, l, &offsets,
|
||||
pfs_crpt_get_auth_off(first_page_id + i, l, &offsets,
|
||||
&aoffset, &asize, &aoff);
|
||||
cap = malloc(sizeof(psync_crypto_auth_page));
|
||||
cap->waiter = NULL;
|
||||
|
|
@ -3181,7 +3181,7 @@ int ppagecache_read_unmod_enc_locked(psync_openfile_t *of,
|
|||
}
|
||||
dp[i].buff = pbuff;
|
||||
dp[i].pagesize = apsize;
|
||||
apageid = pfscrypto_sector_id(first_page_id + i);
|
||||
apageid = pfs_crpt_sector_id(first_page_id + i);
|
||||
rb = check_page_in_memory_by_hash(hash, apageid, pbuff, apsize, 0);
|
||||
if (rb == -1)
|
||||
rb = check_page_in_database_by_hash(hash, apageid, pbuff, apsize, 0);
|
||||
|
|
@ -3199,7 +3199,7 @@ int ppagecache_read_unmod_enc_locked(psync_openfile_t *of,
|
|||
rq->fileid = fileid;
|
||||
rq->hash = hash;
|
||||
rq->needkey = needkey;
|
||||
psync_fs_inc_of_refcnt_and_readers(of);
|
||||
pfs_inc_of_refcnt_and_readers(of);
|
||||
prun_thread1("crypto read unmodified",
|
||||
psync_pagecache_read_unmodified_thread, rq);
|
||||
} else
|
||||
|
|
@ -3207,7 +3207,7 @@ int ppagecache_read_unmod_enc_locked(psync_openfile_t *of,
|
|||
ret = 0;
|
||||
if (needkey) {
|
||||
pdbg_logf(D_NOTICE, "waiting for key to download");
|
||||
psync_fs_lock_file(of);
|
||||
pfs_lock_file(of);
|
||||
while (of->encoder == PSYNC_CRYPTO_LOADING_SECTOR_ENCODER)
|
||||
pthread_cond_wait(&enc_key_cond, &of->mutex);
|
||||
if (of->encoder == PSYNC_CRYPTO_FAILED_SECTOR_ENCODER) {
|
||||
|
|
@ -3232,7 +3232,7 @@ int ppagecache_read_unmod_enc_locked(psync_openfile_t *of,
|
|||
(unsigned long)ap->firstpageid,
|
||||
(unsigned long)ap->firstpageid + ap->size / PSYNC_CRYPTO_AUTH_SIZE,
|
||||
(int)offsets.treelevels);
|
||||
psync_fs_lock_file(of);
|
||||
pfs_lock_file(of);
|
||||
if (likely(of->hash == hash))
|
||||
psync_interval_tree_add(
|
||||
&of->authenticatedints, ap->firstpageid * PSYNC_FS_PAGE_SIZE,
|
||||
|
|
@ -3276,7 +3276,7 @@ int ppagecache_read_unmod_enc_locked(psync_openfile_t *of,
|
|||
} while (p);
|
||||
ap = dp[i].authpage;
|
||||
if (!ret) {
|
||||
psync_fs_lock_file(of);
|
||||
pfs_lock_file(of);
|
||||
if (likely(of->hash == hash))
|
||||
psync_interval_tree_add(
|
||||
&of->authenticatedints, ap->firstpageid * PSYNC_FS_PAGE_SIZE,
|
||||
|
|
@ -3371,7 +3371,7 @@ int ppagecache_readv_locked(psync_openfile_t *of,
|
|||
psync_list_init(&waiting);
|
||||
for (i = 0; i < cnt; i++) {
|
||||
pdbg_assert(ranges[i].offset + ranges[i].size <= of->encrypted
|
||||
? pfscrypto_crypto_size(initialsize)
|
||||
? pfs_crpt_crypto_size(initialsize)
|
||||
: initialsize);
|
||||
poffset = offset_round_down_to_page(ranges[i].offset);
|
||||
pageoff = ranges[i].offset - poffset;
|
||||
|
|
@ -3427,14 +3427,14 @@ int ppagecache_readv_locked(psync_openfile_t *of,
|
|||
rq->fileid = fileid;
|
||||
rq->hash = hash;
|
||||
rq->needkey = needkey;
|
||||
psync_fs_inc_of_refcnt_and_readers(of);
|
||||
pfs_inc_of_refcnt_and_readers(of);
|
||||
prun_thread1("readv unmodified",
|
||||
psync_pagecache_read_unmodified_thread, rq);
|
||||
}
|
||||
ret = 0;
|
||||
if (needkey) {
|
||||
pdbg_logf(D_NOTICE, "waiting for key to download");
|
||||
psync_fs_lock_file(of);
|
||||
pfs_lock_file(of);
|
||||
while (of->encoder == PSYNC_CRYPTO_LOADING_SECTOR_ENCODER)
|
||||
pthread_cond_wait(&enc_key_cond, &of->mutex);
|
||||
if (of->encoder == PSYNC_CRYPTO_FAILED_SECTOR_ENCODER) {
|
||||
|
|
@ -3527,7 +3527,7 @@ static void psync_pagecache_new_upload_to_cache(uint64_t taskid, uint64_t hash,
|
|||
fileidhex[sizeof(psync_fsfileid_t)] = 'd';
|
||||
fileidhex[sizeof(psync_fsfileid_t) + 1] = 0;
|
||||
tm = ptimer_time();
|
||||
filename = psync_strcat(psync_setting_get_string(_PS(fscachepath)),
|
||||
filename = putil_strcat(psync_setting_get_string(_PS(fscachepath)),
|
||||
"/", fileidhex, NULL);
|
||||
fd = pfile_open(filename, O_RDONLY, 0);
|
||||
if (fd == INVALID_HANDLE_VALUE) {
|
||||
|
|
@ -3613,10 +3613,10 @@ static void psync_pagecache_modify_to_cache(uint64_t taskid, uint64_t hash,
|
|||
tm = ptimer_time();
|
||||
cachepath = psync_setting_get_string(_PS(fscachepath));
|
||||
filename =
|
||||
psync_strcat(cachepath, "/", fileidhex, NULL);
|
||||
putil_strcat(cachepath, "/", fileidhex, NULL);
|
||||
fileidhex[sizeof(psync_fsfileid_t)] = 'i';
|
||||
indexname =
|
||||
psync_strcat(cachepath, "/", fileidhex, NULL);
|
||||
putil_strcat(cachepath, "/", fileidhex, NULL);
|
||||
fd = pfile_open(indexname, O_RDONLY, 0);
|
||||
if (unlikely(fd == INVALID_HANDLE_VALUE)) {
|
||||
pdbg_logf(D_ERROR,
|
||||
|
|
@ -3630,7 +3630,7 @@ static void psync_pagecache_modify_to_cache(uint64_t taskid, uint64_t hash,
|
|||
}
|
||||
tree = NULL;
|
||||
if (pdbg_unlikely((fs = pfile_size(fd)) == -1 ||
|
||||
psync_fs_load_interval_tree(fd, fs, &tree) == -1))
|
||||
pfs_load_interval_tree(fd, fs, &tree) == -1))
|
||||
goto err2;
|
||||
pfile_close(fd);
|
||||
fd = pfile_open(filename, O_RDONLY, 0);
|
||||
|
|
@ -3867,7 +3867,7 @@ static void psync_pagecache_upload_to_cache() {
|
|||
psql_run_free(res);
|
||||
psql_commit();
|
||||
if (wake)
|
||||
psync_fsupload_wake();
|
||||
pfs_upld_wake();
|
||||
psync_pagecache_check_free_space();
|
||||
}
|
||||
}
|
||||
|
|
@ -4109,7 +4109,7 @@ void ppagecache_init() {
|
|||
if (stat(cache_dir, &st)) {
|
||||
mkdir(cache_dir, PSYNC_DEFAULT_POSIX_FOLDER_MODE);
|
||||
}
|
||||
cache_file = psync_strcat(cache_dir, "/",
|
||||
cache_file = putil_strcat(cache_dir, "/",
|
||||
PSYNC_DEFAULT_READ_CACHE_FILE, NULL);
|
||||
if (stat(cache_file, &st))
|
||||
psql_statement("DELETE FROM pagecache");
|
||||
|
|
@ -4192,7 +4192,7 @@ void ppagecache_reopen_read() {
|
|||
if (stat(cache_dir, &st)) {
|
||||
mkdir(cache_dir, PSYNC_DEFAULT_POSIX_FOLDER_MODE);
|
||||
}
|
||||
cache_file = psync_strcat(cache_dir, "/",
|
||||
cache_file = putil_strcat(cache_dir, "/",
|
||||
PSYNC_DEFAULT_READ_CACHE_FILE, NULL);
|
||||
readcache = pfile_open(cache_file, O_RDWR, O_CREAT);
|
||||
free(cache_file);
|
||||
|
|
@ -4240,7 +4240,7 @@ int ppagecache_move(const char *path) {
|
|||
int newrdcache, ordcache;
|
||||
uint32_t i, cnt;
|
||||
pdbg_logf(D_NOTICE, "start");
|
||||
rdpath = psync_strcat(path, "/",
|
||||
rdpath = putil_strcat(path, "/",
|
||||
PSYNC_DEFAULT_READ_CACHE_FILE, NULL);
|
||||
if (!stat(rdpath, &st)) {
|
||||
free(rdpath);
|
||||
|
|
@ -4251,7 +4251,7 @@ int ppagecache_move(const char *path) {
|
|||
free(rdpath);
|
||||
return pdbg_return_const(PERROR_CACHE_MOVE_NO_WRITE_ACCESS);
|
||||
}
|
||||
opath = psync_strdup(psync_setting_get_string(_PS(fscachepath)));
|
||||
opath = putil_strdup(psync_setting_get_string(_PS(fscachepath)));
|
||||
pthread_mutex_lock(&clean_cache_mutex);
|
||||
pthread_mutex_lock(&flush_cache_mutex);
|
||||
psql_start();
|
||||
|
|
|
|||
|
|
@ -20,13 +20,13 @@ char *ppath_default_db() {
|
|||
return NULL;
|
||||
}
|
||||
|
||||
dbp = psync_strcat(pcdir, "/", PSYNC_DEFAULT_DB_NAME, NULL);
|
||||
dbp = putil_strcat(pcdir, "/", PSYNC_DEFAULT_DB_NAME, NULL);
|
||||
free(pcdir);
|
||||
|
||||
if (stat(dbp, &st)) {
|
||||
// Inline the old database path function here
|
||||
if ((home = ppath_home())) {
|
||||
oldp = psync_strcat(home, "/", PSYNC_DEFAULT_POSIX_DBNAME, NULL);
|
||||
oldp = putil_strcat(home, "/", PSYNC_DEFAULT_POSIX_DBNAME, NULL);
|
||||
free(home);
|
||||
|
||||
if (oldp) {
|
||||
|
|
@ -69,7 +69,7 @@ char *ppath_home() {
|
|||
return NULL;
|
||||
dir = result->pw_dir;
|
||||
}
|
||||
return psync_strdup(dir);
|
||||
return putil_strdup(dir);
|
||||
}
|
||||
|
||||
int ppath_ls(const char *path, ppath_ls_cb callback, void *ptr) {
|
||||
|
|
@ -100,7 +100,7 @@ int ppath_ls(const char *path, ppath_ls_cb callback, void *ptr) {
|
|||
(de->d_name[1] == 0 || (de->d_name[1] == '.' && de->d_name[2] == 0)))
|
||||
continue;
|
||||
|
||||
psync_strlcpy(cpath + pl, de->d_name, NAME_MAX + 1);
|
||||
putil_strlcpy(cpath + pl, de->d_name, NAME_MAX + 1);
|
||||
|
||||
if (pdbg_likely(!lstat(cpath, &pst.stat)) &&
|
||||
(S_ISREG(pst.stat.st_mode) || S_ISDIR(pst.stat.st_mode))) {
|
||||
|
|
@ -150,7 +150,7 @@ int ppath_ls_fast(const char *path, ppath_ls_fast_cb callback, void *ptr) {
|
|||
callback(ptr, &pst);
|
||||
} else if (de->d_type == DT_UNKNOWN) {
|
||||
// Fall back to lstat for unknown file types
|
||||
psync_strlcpy(cpath + pl, de->d_name, NAME_MAX + 1);
|
||||
putil_strlcpy(cpath + pl, de->d_name, NAME_MAX + 1);
|
||||
if (!pdbg_unlikely(lstat(cpath, &st))) {
|
||||
pst.isfolder = S_ISDIR(st.st_mode);
|
||||
callback(ptr, &pst);
|
||||
|
|
@ -172,7 +172,7 @@ char *ppath_pcloud() {
|
|||
return NULL;
|
||||
}
|
||||
|
||||
path = psync_strcat(homedir, "/", PSYNC_DEFAULT_POSIX_DIR, NULL);
|
||||
path = putil_strcat(homedir, "/", PSYNC_DEFAULT_POSIX_DIR, NULL);
|
||||
free(homedir);
|
||||
if (pdbg_unlikely(!path)) {
|
||||
return NULL;
|
||||
|
|
@ -192,7 +192,7 @@ char *ppath_private(char *name) {
|
|||
path = ppath_pcloud();
|
||||
if (!path)
|
||||
return NULL;
|
||||
rpath = psync_strcat(path, "/", name, NULL);
|
||||
rpath = putil_strcat(path, "/", name, NULL);
|
||||
if (stat(rpath, &st) && mkdir(path, PSYNC_DEFAULT_POSIX_FOLDER_MODE)) {
|
||||
free(rpath);
|
||||
free(path);
|
||||
|
|
|
|||
|
|
@ -339,7 +339,7 @@ void ppathstatus_drive_fldr_changed(psync_folderid_t folderid) {
|
|||
folder_tasks_t *ft;
|
||||
int changed;
|
||||
psql_lock();
|
||||
folder = psync_fstask_get_folder_tasks_rdlocked(folderid);
|
||||
folder = pfs_task_get_folder_tasks_rdlocked(folderid);
|
||||
changed = folder && (folder->creats || folder->mkdirs);
|
||||
ft = get_folder_tasks(folderid, changed);
|
||||
if ((!changed && (!ft || ft->child_task_cnt)) ||
|
||||
|
|
@ -931,7 +931,7 @@ restart:
|
|||
if (off && is_slash(path[off - 1])) {
|
||||
poff = off + 1;
|
||||
} else {
|
||||
folder = psync_fstask_get_folder_tasks_rdlocked(folderid);
|
||||
folder = pfs_task_get_folder_tasks_rdlocked(folderid);
|
||||
if (folder) {
|
||||
if (unlikely(off - poff >= sizeof(buff)))
|
||||
return rdunlock_return(PSYNC_PATH_STATUS_IN_SYNC);
|
||||
|
|
@ -943,9 +943,9 @@ restart:
|
|||
path + poff, off - poff)))
|
||||
return rdunlock_return(PSYNC_PATH_STATUS_IN_SYNC);
|
||||
}
|
||||
if (psync_fstask_find_mkdir(folder, buff, 0))
|
||||
if (pfs_task_find_mkdir(folder, buff, 0))
|
||||
return rdunlock_return_in_prog();
|
||||
if (psync_fstask_find_rmdir(folder, buff, 0))
|
||||
if (pfs_task_find_rmdir(folder, buff, 0))
|
||||
return rdunlock_return(PSYNC_PATH_STATUS_NOT_FOUND);
|
||||
}
|
||||
comp_hash(path + poff, off - poff, hash, folderid, drv_hash_seed);
|
||||
|
|
@ -1016,7 +1016,7 @@ restart:
|
|||
}
|
||||
if (poff == path_len)
|
||||
return psync_path_status_drive_folder_locked(folderid);
|
||||
folder = psync_fstask_get_folder_tasks_rdlocked(folderid);
|
||||
folder = pfs_task_get_folder_tasks_rdlocked(folderid);
|
||||
name = path + poff;
|
||||
namelen = path_len - poff;
|
||||
if (folder) {
|
||||
|
|
@ -1027,9 +1027,9 @@ restart:
|
|||
name = buff;
|
||||
namelen = strlen(buff);
|
||||
}
|
||||
if (psync_fstask_find_mkdir(folder, name, 0))
|
||||
if (pfs_task_find_mkdir(folder, name, 0))
|
||||
return rdunlock_return_in_prog();
|
||||
if (psync_fstask_find_creat(folder, name, 0))
|
||||
if (pfs_task_find_creat(folder, name, 0))
|
||||
return rdunlock_return_in_prog();
|
||||
}
|
||||
// we do the hash with the unencrypted name
|
||||
|
|
@ -1050,12 +1050,12 @@ restart:
|
|||
}
|
||||
if (found) {
|
||||
if (flags & ENTRY_FLAG_FOLDER) {
|
||||
if (folder && psync_fstask_find_rmdir(folder, name, 0))
|
||||
if (folder && pfs_task_find_rmdir(folder, name, 0))
|
||||
return rdunlock_return(PSYNC_PATH_STATUS_NOT_FOUND);
|
||||
else
|
||||
return psync_path_status_drive_folder_locked(folderid);
|
||||
} else {
|
||||
if (folder && psync_fstask_find_unlink(folder, name, 0))
|
||||
if (folder && pfs_task_find_unlink(folder, name, 0))
|
||||
return rdunlock_return(PSYNC_PATH_STATUS_NOT_FOUND);
|
||||
else
|
||||
return rdunlock_return(PSYNC_PATH_STATUS_IN_SYNC);
|
||||
|
|
@ -1073,9 +1073,9 @@ restart:
|
|||
psql_bind_uint(res, 1, folderid);
|
||||
psql_bind_lstr(res, 2, name, namelen);
|
||||
row = psql_fetch_int(res);
|
||||
if (!row || (folder && psync_fstask_find_rmdir(folder, path + poff, 0))) {
|
||||
if (!row || (folder && pfs_task_find_rmdir(folder, path + poff, 0))) {
|
||||
psql_free(res);
|
||||
if (folder && psync_fstask_find_unlink(folder, path + poff, 0))
|
||||
if (folder && pfs_task_find_unlink(folder, path + poff, 0))
|
||||
return rdunlock_return(PSYNC_PATH_STATUS_NOT_FOUND);
|
||||
res = psql_query_nolock(
|
||||
"SELECT id FROM file WHERE parentfolderid=? AND name=?");
|
||||
|
|
@ -1426,7 +1426,7 @@ psync_path_status_t ppathstatus_get(const char *path) {
|
|||
return psync_path_status_drive(path + drive_path_len,
|
||||
len - drive_path_len);
|
||||
} else {
|
||||
dp = psync_fs_getmountpoint();
|
||||
dp = pfs_getmountpoint();
|
||||
if (dp) {
|
||||
// assign the len before the mutex, so we use it as a barrier
|
||||
drive_path_len = strlen(dp);
|
||||
|
|
|
|||
|
|
@ -61,7 +61,7 @@ typedef struct {
|
|||
|
||||
static void lower_patterns(void *ptr);
|
||||
|
||||
static void fsroot_change() { psync_fs_remount(); }
|
||||
static void fsroot_change() { pfs_remount(); }
|
||||
|
||||
#define PSYNC_SETTING_owneremail 16
|
||||
|
||||
|
|
@ -117,11 +117,11 @@ void psync_settings_reset() {
|
|||
char *home, *defaultfs, *defaultcache;
|
||||
psync_settingid_t i;
|
||||
home = ppath_home();
|
||||
defaultfs = psync_strcat(home, "/",
|
||||
defaultfs = putil_strcat(home, "/",
|
||||
PSYNC_DEFAULT_FS_FOLDER, NULL);
|
||||
free(home);
|
||||
home = ppath_pcloud();
|
||||
defaultcache = psync_strcat(home, "/",
|
||||
defaultcache = putil_strcat(home, "/",
|
||||
PSYNC_DEFAULT_CACHE_FOLDER, NULL);
|
||||
free(home);
|
||||
for (i = 0; i < ARRAY_SIZE(settings); i++)
|
||||
|
|
@ -151,7 +151,7 @@ void psync_settings_reset() {
|
|||
settings[_PS(ignorepaths)].str = PSYNC_IGNORE_PATHS_DEFAULT;
|
||||
for (i = 0; i < ARRAY_SIZE(settings); i++) {
|
||||
if (settings[i].type == PSYNC_TSTRING) {
|
||||
settings[i].str = psync_strdup(settings[i].str);
|
||||
settings[i].str = putil_strdup(settings[i].str);
|
||||
if (settings[i].fix_callback)
|
||||
settings[i].fix_callback(&settings[i].str);
|
||||
} else if (settings[i].fix_callback) {
|
||||
|
|
@ -172,11 +172,11 @@ void psync_settings_init() {
|
|||
char *home, *defaultfs, *defaultcache;
|
||||
psync_settingid_t i;
|
||||
home = ppath_home();
|
||||
defaultfs = psync_strcat(home, "/",
|
||||
defaultfs = putil_strcat(home, "/",
|
||||
PSYNC_DEFAULT_FS_FOLDER, NULL);
|
||||
free(home);
|
||||
home = ppath_pcloud();
|
||||
defaultcache = psync_strcat(home, "/",
|
||||
defaultcache = putil_strcat(home, "/",
|
||||
PSYNC_DEFAULT_CACHE_FOLDER, NULL);
|
||||
free(home);
|
||||
settings[_PS(ignorepatterns)].str = PSYNC_IGNORE_PATTERNS_DEFAULT;
|
||||
|
|
@ -195,7 +195,7 @@ void psync_settings_init() {
|
|||
settings[_PS(ignorepaths)].str = PSYNC_IGNORE_PATHS_DEFAULT;
|
||||
for (i = 0; i < ARRAY_SIZE(settings); i++) {
|
||||
if (settings[i].type == PSYNC_TSTRING) {
|
||||
settings[i].str = psync_strdup(settings[i].str);
|
||||
settings[i].str = putil_strdup(settings[i].str);
|
||||
if (settings[i].fix_callback)
|
||||
settings[i].fix_callback(&settings[i].str);
|
||||
} else if (settings[i].fix_callback) {
|
||||
|
|
@ -214,7 +214,7 @@ void psync_settings_init() {
|
|||
if (!strcmp(name, settings[i].name)) {
|
||||
if (settings[i].type == PSYNC_TSTRING) {
|
||||
free(settings[i].str);
|
||||
settings[i].str = psync_strdup(row[1]);
|
||||
settings[i].str = putil_strdup(row[1]);
|
||||
if (settings[i].fix_callback)
|
||||
settings[i].fix_callback(&settings[i].str);
|
||||
} else if (settings[i].type == PSYNC_TNUMBER) {
|
||||
|
|
@ -333,7 +333,7 @@ int psync_setting_set_string(psync_settingid_t settingid, const char *value) {
|
|||
char *oldval, *newval;
|
||||
CHECK_SETTINGID_AND_TYPE(-1, PSYNC_TSTRING);
|
||||
oldval = settings[settingid].str;
|
||||
newval = psync_strdup(value);
|
||||
newval = putil_strdup(value);
|
||||
if (settings[settingid].fix_callback)
|
||||
settings[settingid].fix_callback(&newval);
|
||||
settings[settingid].str = newval;
|
||||
|
|
|
|||
|
|
@ -461,7 +461,7 @@ psock_t *psock_connect(const char *host, int unsigned port, int ssl) {
|
|||
void *sslc;
|
||||
int sock;
|
||||
char sport[8];
|
||||
psync_slprintf(sport, sizeof(sport), "%d", port);
|
||||
putil_slprintf(sport, sizeof(sport), "%d", port);
|
||||
|
||||
sock = connect_socket(host, sport);
|
||||
if (pdbg_unlikely(sock == INVALID_SOCKET)) {
|
||||
|
|
|
|||
|
|
@ -199,7 +199,7 @@ void psql_dump_locks() {
|
|||
rd_lock_data *lock;
|
||||
char dttime[36];
|
||||
if (wrlocked) {
|
||||
time_format(lockstart.tv_sec, lockstart.tv_nsec, dttime);
|
||||
putil_time_format(lockstart.tv_sec, lockstart.tv_nsec, dttime);
|
||||
pdbg_logf(D_ERROR, "write lock taken by thread %s from %s:%u at %s",
|
||||
wrlockthread, wrlockfile, wrlockline, dttime);
|
||||
sendpdbg_logf("write lock taken by thread %s from %s:%u at %s", wrlockthread,
|
||||
|
|
@ -207,7 +207,7 @@ void psql_dump_locks() {
|
|||
}
|
||||
pthread_mutex_lock(&rdmutex);
|
||||
psync_list_for_each_element(lock, &rdlocks, rd_lock_data, list) {
|
||||
time_format(lock->tm.tv_sec, lock->tm.tv_nsec, dttime);
|
||||
putil_time_format(lock->tm.tv_sec, lock->tm.tv_nsec, dttime);
|
||||
pdbg_logf(D_ERROR, "read lock taken by thread %s from %s:%u at %s",
|
||||
lock->thread, lock->file, lock->line, dttime);
|
||||
sendpdbg_logf("read lock taken by thread %s from %s:%u at %s", lock->thread,
|
||||
|
|
@ -628,7 +628,7 @@ char *psql_cellstr(const char *sql) {
|
|||
char *ret;
|
||||
ret = (char *)sqlite3_column_text(stmt, 0);
|
||||
if (ret)
|
||||
ret = psync_strdup(ret);
|
||||
ret = putil_strdup(ret);
|
||||
sqlite3_finalize(stmt);
|
||||
psql_rdunlock();
|
||||
return ret;
|
||||
|
|
|
|||
|
|
@ -704,7 +704,7 @@ char *psymkey_derive(const char *username,
|
|||
mbedtls_pkcs5_pbkdf2_hmac(&ctx, (const unsigned char *)passphrase, strlen(passphrase), usersha512,
|
||||
PSYNC_SHA512_DIGEST_LEN, 5000, sizeof(passwordbin), passwordbin);
|
||||
mbedtls_md_free(&ctx);
|
||||
usercopy = psync_base64_encode(passwordbin, sizeof(passwordbin), &userlen);
|
||||
usercopy = putil_base64_encode(passwordbin, sizeof(passwordbin), &userlen);
|
||||
return (char *)usercopy;
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -218,7 +218,7 @@ void pstatus_upload_recalc() {
|
|||
fileidhex[sizeof(psync_fsfileid_t)] = 'd';
|
||||
fileidhex[sizeof(psync_fsfileid_t) + 1] = 0;
|
||||
filename =
|
||||
psync_strcat(fscpath, "/", fileidhex, NULL);
|
||||
putil_strcat(fscpath, "/", fileidhex, NULL);
|
||||
if (!stat(filename, &st)) {
|
||||
filestou++;
|
||||
bytestou += pfile_stat_size(&st);
|
||||
|
|
|
|||
|
|
@ -222,7 +222,7 @@ psuggested_folders_t *psuggest_scan_folder(const char *path) {
|
|||
qsort(scnt, PSYNC_SCAN_TYPES_CNT, sizeof(scnt[0]), sort_comp_tuple_rev);
|
||||
for (i = 0; i < PSYNC_SCAN_TYPES_CNT; i++)
|
||||
if (scnt[i][1] && scnt[i][0] >= PSYNC_SCANNER_MIN_DISPLAY) {
|
||||
off += psync_slprintf(buff + off, sizeof(buff) - off, "%u %s, ",
|
||||
off += putil_slprintf(buff + off, sizeof(buff) - off, "%u %s, ",
|
||||
(unsigned)scnt[i][0],
|
||||
psync_scan_typenames[scnt[i][1]]);
|
||||
if (off >= sizeof(buff))
|
||||
|
|
|
|||
|
|
@ -192,7 +192,7 @@ psync_folderid_t psyncer_db_folder_create(
|
|||
for (ptr = name; *ptr; ptr++)
|
||||
if (pfile_invalid_chars[(unsigned char)*ptr]) {
|
||||
if (!vname)
|
||||
vname = psync_strdup(name);
|
||||
vname = putil_strdup(name);
|
||||
vname[ptr - name] = '_';
|
||||
}
|
||||
if (vname)
|
||||
|
|
@ -307,7 +307,7 @@ static void psync_sync_newsyncedfolder(psync_syncid_t syncid) {
|
|||
folderid = psync_get_number(row[0]);
|
||||
synctype = psync_get_number(row[1]);
|
||||
localpath =
|
||||
psync_strndup(psync_get_string(row[2]), strlen(psync_get_string(row[2])));
|
||||
putil_strndup(psync_get_string(row[2]), strlen(psync_get_string(row[2])));
|
||||
psql_free(res);
|
||||
if (synctype & PSYNC_DOWNLOAD_ONLY) {
|
||||
psyncer_dl_folder_add(syncid, synctype, folderid, 0);
|
||||
|
|
@ -463,8 +463,8 @@ re:
|
|||
continue;
|
||||
}
|
||||
|
||||
localpath = psync_strdup(localpath);
|
||||
remotepath = psync_strdup(remotepath);
|
||||
localpath = putil_strdup(localpath);
|
||||
remotepath = putil_strdup(remotepath);
|
||||
psql_free(res);
|
||||
|
||||
folderid = pfolder_id_create(remotepath);
|
||||
|
|
|
|||
|
|
@ -112,7 +112,7 @@ static inline int psync_status_is_offline() {
|
|||
uint32_t psync_get_last_error() { return psync_error; }
|
||||
|
||||
void psync_set_database_path(const char *databasepath) {
|
||||
psync_database = psync_strdup(databasepath);
|
||||
psync_database = putil_strdup(databasepath);
|
||||
}
|
||||
|
||||
static void psync_stop_crypto_on_sleep() {
|
||||
|
|
@ -235,7 +235,7 @@ void psync_start_sync(pstatus_change_callback_t status_callback,
|
|||
psync_localscan_init();
|
||||
pp2p_init();
|
||||
if (psync_setting_get_bool(_PS(autostartfs)))
|
||||
psync_fs_start();
|
||||
pfs_start();
|
||||
pdevmon_init();
|
||||
}
|
||||
|
||||
|
|
@ -255,7 +255,7 @@ void psync_destroy() {
|
|||
if (pshm_cleanup() == -1) {
|
||||
pdbg_logf(D_ERROR, "failed to cleanup shm");
|
||||
}
|
||||
psync_fs_stop();
|
||||
pfs_stop();
|
||||
pstatus_wait_term();
|
||||
pstatus_send_status_update();
|
||||
ptask_stop_async();
|
||||
|
|
@ -288,10 +288,10 @@ void psync_set_user_pass(const char *username, const char *password, int save) {
|
|||
} else {
|
||||
pthread_mutex_lock(&psync_my_auth_mutex);
|
||||
free(psync_my_user);
|
||||
psync_my_user = psync_strdup(username);
|
||||
psync_my_user = putil_strdup(username);
|
||||
free(psync_my_pass);
|
||||
if (password && password[0])
|
||||
psync_my_pass = psync_strdup(password);
|
||||
psync_my_pass = putil_strdup(password);
|
||||
pthread_mutex_unlock(&psync_my_auth_mutex);
|
||||
}
|
||||
pstatus_set(PSTATUS_TYPE_AUTH, PSTATUS_AUTH_PROVIDED);
|
||||
|
|
@ -305,7 +305,7 @@ void psync_set_pass(const char *password, int save) {
|
|||
else {
|
||||
pthread_mutex_lock(&psync_my_auth_mutex);
|
||||
free(psync_my_pass);
|
||||
psync_my_pass = psync_strdup(password);
|
||||
psync_my_pass = putil_strdup(password);
|
||||
pthread_mutex_unlock(&psync_my_auth_mutex);
|
||||
}
|
||||
pstatus_set(PSTATUS_TYPE_AUTH, PSTATUS_AUTH_PROVIDED);
|
||||
|
|
@ -316,7 +316,7 @@ void psync_set_auth(const char *auth, int save) {
|
|||
if (save)
|
||||
psync_set_string_value("auth", auth);
|
||||
else
|
||||
psync_strlcpy(psync_my_auth, auth, sizeof(psync_my_auth));
|
||||
putil_strlcpy(psync_my_auth, auth, sizeof(psync_my_auth));
|
||||
pstatus_set(PSTATUS_TYPE_AUTH, PSTATUS_AUTH_PROVIDED);
|
||||
}
|
||||
|
||||
|
|
@ -350,7 +350,7 @@ void psync_logout(uint32_t auth_status, int doinvauth) {
|
|||
pstatus_set(PSTATUS_TYPE_ONLINE, PSTATUS_ONLINE_CONNECTING);
|
||||
pstatus_set(PSTATUS_TYPE_AUTH, auth_status);
|
||||
|
||||
psync_fs_pause_until_login();
|
||||
pfs_pause_until_login();
|
||||
pdownload_stop_all();
|
||||
pupload_stop_all();
|
||||
ptask_stop_async();
|
||||
|
|
@ -358,8 +358,8 @@ void psync_logout(uint32_t auth_status, int doinvauth) {
|
|||
psync_set_apiserver(PSYNC_API_HOST, PSYNC_LOCATIONID_DEFAULT);
|
||||
psync_restart_localscan();
|
||||
ptimer_notify_exception();
|
||||
if (psync_fs_need_per_folder_refresh()) {
|
||||
psync_fs_refresh_folder(0);
|
||||
if (pfs_need_per_folder_refresh()) {
|
||||
pfs_refresh_folder(0);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -380,7 +380,7 @@ apiservers_list_t *psync_get_apiservers(char **err) {
|
|||
|
||||
if (unlikely(!api)) {
|
||||
pdbg_logf(D_WARNING, "Can't get api from the pool. No pool ?\n");
|
||||
*err = psync_strndup("Can't get api from the pool.", 29);
|
||||
*err = putil_strndup("Can't get api from the pool.", 29);
|
||||
return NULL;
|
||||
}
|
||||
bres = papi_send2(api, "getlocationapi", params);
|
||||
|
|
@ -389,13 +389,13 @@ apiservers_list_t *psync_get_apiservers(char **err) {
|
|||
else {
|
||||
psync_apipool_release_bad(api);
|
||||
pdbg_logf(D_WARNING, "Send command returned invalid result.\n");
|
||||
*err = psync_strndup("Connection error.", 17);
|
||||
*err = putil_strndup("Connection error.", 17);
|
||||
return NULL;
|
||||
}
|
||||
result = papi_find_result2(bres, "result", PARAM_NUM)->num;
|
||||
if (unlikely(result)) {
|
||||
errorret = papi_find_result2(bres, "error", PARAM_STR)->str;
|
||||
*err = psync_strndup(errorret, strlen(errorret));
|
||||
*err = putil_strndup(errorret, strlen(errorret));
|
||||
pdbg_logf(D_WARNING, "command getlocationapi returned error code %u",
|
||||
(unsigned)result);
|
||||
return NULL;
|
||||
|
|
@ -492,8 +492,8 @@ void psync_unlink() {
|
|||
pthread_mutex_unlock(&psync_my_auth_mutex);
|
||||
pdbg_logf(D_NOTICE, "clearing database, finished");
|
||||
|
||||
psync_fs_pause_until_login();
|
||||
psync_fs_clean_tasks();
|
||||
pfs_pause_until_login();
|
||||
pfs_clean_tasks();
|
||||
ppathstatus_init();
|
||||
psyncer_dl_queue_clear();
|
||||
psql_unlock();
|
||||
|
|
@ -508,8 +508,8 @@ void psync_unlink() {
|
|||
pstatus_set(PSTATUS_TYPE_AUTH, PSTATUS_AUTH_REQUIRED);
|
||||
pstatus_set(PSTATUS_TYPE_RUN, PSTATUS_RUN_RUN);
|
||||
psync_resume_localscan();
|
||||
if (psync_fs_need_per_folder_refresh()) {
|
||||
psync_fs_refresh_folder(0);
|
||||
if (pfs_need_per_folder_refresh()) {
|
||||
pfs_refresh_folder(0);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -529,9 +529,9 @@ static void check_tfa_result(uint64_t result) {
|
|||
|
||||
static char *binresult_to_str(const binresult *res) {
|
||||
if (!res)
|
||||
return psync_strdup("field not found");
|
||||
return putil_strdup("field not found");
|
||||
if (res->type == PARAM_STR)
|
||||
return psync_strdup(res->str);
|
||||
return putil_strdup(res->str);
|
||||
else if (res->type == PARAM_NUM) {
|
||||
char buff[32], *ptr;
|
||||
uint64_t n;
|
||||
|
|
@ -542,9 +542,9 @@ static char *binresult_to_str(const binresult *res) {
|
|||
*--ptr = '0' + n % 10;
|
||||
n /= 10;
|
||||
} while (n);
|
||||
return psync_strdup(ptr);
|
||||
return putil_strdup(ptr);
|
||||
} else {
|
||||
return psync_strdup("bad field type");
|
||||
return putil_strdup("bad field type");
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -905,7 +905,7 @@ static int do_run_command_get_res(const char *cmd, size_t cmdlen,
|
|||
if (result) {
|
||||
pdbg_logf(D_WARNING, "command %s returned code %u", cmd, (unsigned)result);
|
||||
if (err)
|
||||
*err = psync_strdup(papi_find_result2(res, "error", PARAM_STR)->str);
|
||||
*err = putil_strdup(papi_find_result2(res, "error", PARAM_STR)->str);
|
||||
psync_process_api_error(result);
|
||||
}
|
||||
if (result)
|
||||
|
|
@ -915,7 +915,7 @@ static int do_run_command_get_res(const char *cmd, size_t cmdlen,
|
|||
return (int)result;
|
||||
neterr:
|
||||
if (err)
|
||||
*err = psync_strdup("Could not connect to the server.");
|
||||
*err = putil_strdup("Could not connect to the server.");
|
||||
return -1;
|
||||
}
|
||||
|
||||
|
|
@ -931,14 +931,14 @@ int psync_register(const char *email, const char *password, int termsaccepted,
|
|||
psync_set_apiserver(binapi, locationid);
|
||||
else {
|
||||
if (err)
|
||||
*err = psync_strdup("Could not connect to the server.");
|
||||
*err = putil_strdup("Could not connect to the server.");
|
||||
psync_set_apiserver(PSYNC_API_HOST, PSYNC_LOCATIONID_DEFAULT);
|
||||
return -1;
|
||||
}
|
||||
sock = papi_connect(binapi, psync_setting_get_bool(_PS(usessl)));
|
||||
if (pdbg_unlikely(!sock)) {
|
||||
if (err)
|
||||
*err = psync_strdup("Could not connect to the server.");
|
||||
*err = putil_strdup("Could not connect to the server.");
|
||||
psync_set_apiserver(PSYNC_API_HOST, PSYNC_LOCATIONID_DEFAULT);
|
||||
return -1;
|
||||
}
|
||||
|
|
@ -946,7 +946,7 @@ int psync_register(const char *email, const char *password, int termsaccepted,
|
|||
if (pdbg_unlikely(!res)) {
|
||||
psock_close(sock);
|
||||
if (err)
|
||||
*err = psync_strdup("Could not connect to the server.");
|
||||
*err = putil_strdup("Could not connect to the server.");
|
||||
psync_set_apiserver(PSYNC_API_HOST, PSYNC_LOCATIONID_DEFAULT);
|
||||
return -1;
|
||||
}
|
||||
|
|
@ -954,7 +954,7 @@ int psync_register(const char *email, const char *password, int termsaccepted,
|
|||
if (result) {
|
||||
pdbg_logf(D_WARNING, "command register returned code %u", (unsigned)result);
|
||||
if (err)
|
||||
*err = psync_strdup(papi_find_result2(res, "error", PARAM_STR)->str);
|
||||
*err = putil_strdup(papi_find_result2(res, "error", PARAM_STR)->str);
|
||||
psync_set_apiserver(PSYNC_API_HOST, PSYNC_LOCATIONID_DEFAULT);
|
||||
}
|
||||
psock_close(sock);
|
||||
|
|
@ -993,7 +993,7 @@ int psync_change_password(const char *currentpass, const char *newpass,
|
|||
free(device);
|
||||
if (ret)
|
||||
return ret;
|
||||
psync_strlcpy(psync_my_auth, papi_find_result2(res, "auth", PARAM_STR)->str,
|
||||
putil_strlcpy(psync_my_auth, papi_find_result2(res, "auth", PARAM_STR)->str,
|
||||
sizeof(psync_my_auth));
|
||||
free(res);
|
||||
return 0;
|
||||
|
|
@ -1130,7 +1130,7 @@ char *psync_get_string_value(const char *valuename) {
|
|||
psql_bind_str(res, 1, valuename);
|
||||
row = psql_fetch_str(res);
|
||||
if (row)
|
||||
ret = psync_strdup(row[0]);
|
||||
ret = putil_strdup(row[0]);
|
||||
else
|
||||
ret = NULL;
|
||||
psql_free(res);
|
||||
|
|
@ -1495,7 +1495,7 @@ static void psync_del_all_except(void *ptr, ppath_fast_stat *st) {
|
|||
nmarr = (const char **)ptr;
|
||||
if (!strcmp(st->name, nmarr[1]) || pfile_stat_fast_isfolder(st))
|
||||
return;
|
||||
fp = psync_strcat(nmarr[0], "/", st->name, NULL);
|
||||
fp = putil_strcat(nmarr[0], "/", st->name, NULL);
|
||||
pdbg_logf(D_NOTICE, "deleting old update file %s", fp);
|
||||
if (pfile_delete(fp))
|
||||
pdbg_logf(D_WARNING, "could not delete %s", fp);
|
||||
|
|
@ -1516,7 +1516,7 @@ static char *psync_filename_from_res(const binresult *res) {
|
|||
nmarr[0] = path;
|
||||
nmarr[1] = nmd;
|
||||
ppath_ls_fast(path, psync_del_all_except, (void *)nmarr);
|
||||
ret = psync_strcat(path, "/", nmd, NULL);
|
||||
ret = putil_strcat(path, "/", nmd, NULL);
|
||||
free(nmd);
|
||||
free(path);
|
||||
return ret;
|
||||
|
|
@ -2097,15 +2097,15 @@ int psync_setlanguage(const char *language, char **err) {
|
|||
return psync_run_command("setlanguage", params, err);
|
||||
}
|
||||
|
||||
void psync_fs_clean_read_cache() { ppagecache_clean_read(); }
|
||||
void pfs_clean_read_cache() { ppagecache_clean_read(); }
|
||||
|
||||
int psync_fs_move_cache(const char *path) {
|
||||
int pfs_move_cache(const char *path) {
|
||||
return ppagecache_move(path);
|
||||
}
|
||||
|
||||
char *psync_get_token() {
|
||||
if (psync_my_auth[0])
|
||||
return psync_strdup(psync_my_auth);
|
||||
return putil_strdup(psync_my_auth);
|
||||
else
|
||||
return NULL;
|
||||
}
|
||||
|
|
@ -2136,7 +2136,7 @@ int psync_get_promo(char **url, uint64_t *width, uint64_t *height) {
|
|||
return result;
|
||||
}
|
||||
|
||||
*url = psync_strdup(papi_find_result2(res, "url", PARAM_STR)->str);
|
||||
*url = putil_strdup(papi_find_result2(res, "url", PARAM_STR)->str);
|
||||
|
||||
if (!papi_find_result2(res, "width", PARAM_NUM)->num) {
|
||||
pdbg_logf(D_NOTICE, "Parameter width not found.");
|
||||
|
|
@ -2166,12 +2166,12 @@ int psync_get_promo(char **url, uint64_t *width, uint64_t *height) {
|
|||
psync_folderid_t psync_get_fsfolderid_by_path(const char *path,
|
||||
uint32_t *pflags,
|
||||
uint32_t *pPerm) {
|
||||
return psync_fsfolderidperm_by_path(path, pflags, pPerm);
|
||||
return pfs_fldr_idperm_by_path(path, pflags, pPerm);
|
||||
}
|
||||
|
||||
uint32_t psync_get_fsfolderflags_by_id(psync_folderid_t folderid,
|
||||
uint32_t *pPerm) {
|
||||
return psync_fsfolderflags_by_id(folderid, pPerm);
|
||||
return pfs_fldr_flags_by_id(folderid, pPerm);
|
||||
}
|
||||
|
||||
uint64_t psync_crypto_priv_key_flags() {
|
||||
|
|
@ -2241,13 +2241,13 @@ int psync_is_folder_syncable(char *localPath, char **errMsg) {
|
|||
if (psyncer_str_has_prefix(srow[0], localPath)) {
|
||||
psql_free(sql);
|
||||
|
||||
*errMsg = psync_strdup("There is already an active sync or backup for a "
|
||||
*errMsg = putil_strdup("There is already an active sync or backup for a "
|
||||
"parent of this folder.");
|
||||
return PERROR_PARENT_OR_SUBFOLDER_ALREADY_SYNCING;
|
||||
} else if (!strcmp(srow[0], localPath)) {
|
||||
psql_free(sql);
|
||||
|
||||
*errMsg = psync_strdup(
|
||||
*errMsg = putil_strdup(
|
||||
"There is already an active sync or backup for this folder.");
|
||||
return PERROR_FOLDER_ALREADY_SYNCING;
|
||||
}
|
||||
|
|
@ -2256,7 +2256,7 @@ int psync_is_folder_syncable(char *localPath, char **errMsg) {
|
|||
|
||||
pdbg_logf(D_NOTICE, "Check if folder is not on the Drive.");
|
||||
|
||||
syncmp = psync_fs_getmountpoint();
|
||||
syncmp = pfs_getmountpoint();
|
||||
|
||||
pdbg_logf(D_NOTICE, "Mount point: [%s].", syncmp);
|
||||
if (syncmp) {
|
||||
|
|
@ -2268,7 +2268,7 @@ int psync_is_folder_syncable(char *localPath, char **errMsg) {
|
|||
localPath[len] == '\\')) {
|
||||
free(syncmp);
|
||||
|
||||
*errMsg = psync_strdup("Folder is located on pCloud drive.");
|
||||
*errMsg = putil_strdup("Folder is located on pCloud drive.");
|
||||
return PERROR_LOCAL_IS_ON_PDRIVE;
|
||||
}
|
||||
free(syncmp);
|
||||
|
|
@ -2283,7 +2283,7 @@ int psync_is_folder_syncable(char *localPath, char **errMsg) {
|
|||
localPath);
|
||||
|
||||
if (psyncer_str_starts_with(folders.folders[i], localPath)) {
|
||||
*errMsg = psync_strdup(
|
||||
*errMsg = putil_strdup(
|
||||
"This folder is a child of a folder in your ignore folders list.");
|
||||
return PERROR_PARENT_IS_IGNORED;
|
||||
}
|
||||
|
|
@ -2304,7 +2304,7 @@ psync_folderid_t create_bup_mach_folder(char **msgErr) {
|
|||
|
||||
rootFolIdObj = NULL;
|
||||
tmpBuff = get_pc_name();
|
||||
psync_strlcpy(bRootFoName, tmpBuff, 64);
|
||||
putil_strlcpy(bRootFoName, tmpBuff, 64);
|
||||
|
||||
free(tmpBuff);
|
||||
|
||||
|
|
@ -2377,10 +2377,10 @@ int psync_create_backup(char *path, char **errMsg) {
|
|||
|
||||
if (folders.cnt > 1) {
|
||||
oParCnt = 1;
|
||||
optFolName = psync_strdup(folders.folders[folders.cnt - 2]);
|
||||
optFolName = putil_strdup(folders.folders[folders.cnt - 2]);
|
||||
} else {
|
||||
oParCnt = 0;
|
||||
optFolName = psync_strdup("");
|
||||
optFolName = putil_strdup("");
|
||||
}
|
||||
|
||||
eventParams reqPar = {4, // Number of parameters we are passing below.
|
||||
|
|
@ -2406,7 +2406,7 @@ int psync_create_backup(char *path, char **errMsg) {
|
|||
free(retData);
|
||||
|
||||
if (syncFId < 0) {
|
||||
*errMsg = psync_strdup("Error creating backup.");
|
||||
*errMsg = putil_strdup("Error creating backup.");
|
||||
return syncFId;
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -1118,13 +1118,13 @@ int psync_upload_file_as(const char *remote_path, const char *remote_filename,
|
|||
|
||||
/* Filesystem functions.
|
||||
*
|
||||
* psync_fs_start() - starts the filesystem
|
||||
* psync_fs_isstarted() - returns 1 if the filesystem is started and 0 otherwise
|
||||
* psync_fs_stop() - stops the filesystem
|
||||
* psync_fs_getmountpoint() - returns current mountpoint of the filesystem, or
|
||||
* pfs_start() - starts the filesystem
|
||||
* pfs_isstarted() - returns 1 if the filesystem is started and 0 otherwise
|
||||
* pfs_stop() - stops the filesystem
|
||||
* pfs_getmountpoint() - returns current mountpoint of the filesystem, or
|
||||
* NULL if the filesystem is not mounted, you are supposed to free the returned
|
||||
* pointer psync_fs_register_start_callback() - registers a callback that will
|
||||
* be called once the drive is started psync_fs_get_path_by_folderid() - returns
|
||||
* pointer pfs_register_start_callback() - registers a callback that will
|
||||
* be called once the drive is started pfs_get_path_by_folderid() - returns
|
||||
* full path (including mountpoint) of a given folderid on the filesystem or
|
||||
* NULL if it is not mounted or folder could not be
|
||||
* found. You are supposed to free the returned pointer.
|
||||
|
|
@ -1132,7 +1132,7 @@ int psync_upload_file_as(const char *remote_path, const char *remote_filename,
|
|||
* fileid on the filesystem or NULL if it is not mounted or parent folder could
|
||||
* not be found. You are supposed to free the returned pointer.
|
||||
*
|
||||
* psync_fs_clean_read_cache() - cleans the filesystem read cache. This function
|
||||
* pfs_clean_read_cache() - cleans the filesystem read cache. This function
|
||||
* does not fail. The general expectation is that the function takes some
|
||||
* moderate time to execute - maybe 0.5-2 seconds depending on the system and
|
||||
* it's load. In the unlikely case of cache flush or cache garbage collection
|
||||
|
|
@ -1141,9 +1141,9 @@ int psync_upload_file_as(const char *remote_path, const char *remote_filename,
|
|||
* filesystem operations will hang and wait for the process to finish, so please
|
||||
* design the UI accordingly.
|
||||
*
|
||||
* psync_fs_move_cache() - cleans filesystem read cache and moves both read
|
||||
* pfs_move_cache() - cleans filesystem read cache and moves both read
|
||||
* cache and write queue to specified directory. The function has the same
|
||||
* overall complexity as psync_fs_clean_read_cache(). Returns 0 on success,
|
||||
* overall complexity as pfs_clean_read_cache(). Returns 0 on success,
|
||||
* PERROR_CACHE_MOVE_NOT_EMPTY if the target directory already has a read cache
|
||||
* file in it, PERROR_CACHE_MOVE_NO_WRITE_ACCESS if request to open a file for
|
||||
* writing in the provided directory fails or PERROR_CACHE_MOVE_DRIVE_HAS_TASKS
|
||||
|
|
@ -1152,16 +1152,16 @@ int psync_upload_file_as(const char *remote_path, const char *remote_filename,
|
|||
*
|
||||
*/
|
||||
|
||||
int psync_fs_start();
|
||||
int psync_fs_isstarted();
|
||||
void psync_fs_stop();
|
||||
char *psync_fs_getmountpoint();
|
||||
void psync_fs_register_start_callback(psync_generic_callback_t callback);
|
||||
char *psync_fs_get_path_by_folderid(psync_folderid_t folderid);
|
||||
char *psync_fs_get_path_by_fileid(psync_fileid_t fileid);
|
||||
int pfs_start();
|
||||
int pfs_isstarted();
|
||||
void pfs_stop();
|
||||
char *pfs_getmountpoint();
|
||||
void pfs_register_start_callback(psync_generic_callback_t callback);
|
||||
char *pfs_get_path_by_folderid(psync_folderid_t folderid);
|
||||
char *pfs_get_path_by_fileid(psync_fileid_t fileid);
|
||||
|
||||
void psync_fs_clean_read_cache();
|
||||
int psync_fs_move_cache(const char *path);
|
||||
void pfs_clean_read_cache();
|
||||
int pfs_move_cache(const char *path);
|
||||
|
||||
/* psync_password_quality estimates password quality, returns one of:
|
||||
* 0 - weak
|
||||
|
|
|
|||
|
|
@ -457,7 +457,7 @@ static int handle_download(async_params_t *prms,
|
|||
s->process_data = download_process_headers;
|
||||
fda->localpath = dwl->localpath;
|
||||
fda->fd = INVALID_HANDLE_VALUE;
|
||||
len = psync_slprintf(buff, sizeof(buff),
|
||||
len = putil_slprintf(buff, sizeof(buff),
|
||||
"act=dwl,strm=%" PRIu64 ",fileid=%" PRIu64 "\n",
|
||||
(uint64_t)s->streamid, (uint64_t)dwl->fileid);
|
||||
if (data_send(prms, buff, len)) {
|
||||
|
|
@ -488,7 +488,7 @@ static int handle_download_nm(async_params_t *prms,
|
|||
memcpy(fda->osha1hex, dwl->sha1hex, PSYNC_SHA1_DIGEST_HEXLEN);
|
||||
fda->localpath = dwl->localpath;
|
||||
fda->fd = INVALID_HANDLE_VALUE;
|
||||
len = psync_slprintf(
|
||||
len = putil_slprintf(
|
||||
buff, sizeof(buff),
|
||||
"act=dwlnm,strm=%" PRIu64 ",fileid=%" PRIu64 ",sha1=%.40s\n",
|
||||
(uint64_t)s->streamid, (uint64_t)dwl->fileid, dwl->sha1hex);
|
||||
|
|
|
|||
|
|
@ -76,10 +76,10 @@ char *ptools_get_mac_addr() {
|
|||
buffer[12] = 0;
|
||||
|
||||
if (buffer[0] == 0) {
|
||||
return psync_strdup("GENERIC_MAC");
|
||||
return putil_strdup("GENERIC_MAC");
|
||||
|
||||
} else {
|
||||
return psync_strdup(buffer);
|
||||
return putil_strdup(buffer);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -102,7 +102,7 @@ int ptools_create_backend_event(const char *binapi, const char *category,
|
|||
|
||||
if (pdbg_unlikely(!sock)) {
|
||||
if (err) {
|
||||
*err = psync_strdup("Could not connect to the server.");
|
||||
*err = putil_strdup("Could not connect to the server.");
|
||||
}
|
||||
|
||||
return -1;
|
||||
|
|
@ -189,7 +189,7 @@ int ptools_create_backend_event(const char *binapi, const char *category,
|
|||
psock_close(sock);
|
||||
|
||||
if (err) {
|
||||
*err = psync_strdup("Could not connect to the server.");
|
||||
*err = putil_strdup("Could not connect to the server.");
|
||||
}
|
||||
|
||||
return -1;
|
||||
|
|
@ -201,7 +201,7 @@ int ptools_create_backend_event(const char *binapi, const char *category,
|
|||
|
||||
if (result) {
|
||||
if (err) {
|
||||
*err = psync_strdup(papi_find_result2(res, "error", PARAM_STR)->str);
|
||||
*err = putil_strdup(papi_find_result2(res, "error", PARAM_STR)->str);
|
||||
}
|
||||
|
||||
pdbg_logf(D_CRITICAL, "Event command failed. Error:[%s]", *err);
|
||||
|
|
@ -298,7 +298,7 @@ int ptools_backend_call(const char *binapi, const char *wsPath,
|
|||
|
||||
if (pdbg_unlikely(!sock)) {
|
||||
if (err) {
|
||||
*err = psync_strdup("Could not connect to the server.");
|
||||
*err = putil_strdup("Could not connect to the server.");
|
||||
}
|
||||
|
||||
return -1;
|
||||
|
|
@ -313,7 +313,7 @@ int ptools_backend_call(const char *binapi, const char *wsPath,
|
|||
psock_close(sock);
|
||||
|
||||
if (err) {
|
||||
*err = psync_strdup("Could not connect to the server.");
|
||||
*err = putil_strdup("Could not connect to the server.");
|
||||
}
|
||||
|
||||
return -1;
|
||||
|
|
@ -325,7 +325,7 @@ int ptools_backend_call(const char *binapi, const char *wsPath,
|
|||
|
||||
if (result) {
|
||||
if (err) {
|
||||
*err = psync_strdup(papi_find_result2(res, "error", PARAM_STR)->str);
|
||||
*err = putil_strdup(papi_find_result2(res, "error", PARAM_STR)->str);
|
||||
}
|
||||
|
||||
pdbg_logf(D_CRITICAL, "Backend command failed. Error:[%s]", *err);
|
||||
|
|
@ -353,7 +353,7 @@ char *ptools_get_machine_name() {
|
|||
strcpy(pcName, "LinuxMachine");
|
||||
}
|
||||
|
||||
return psync_strdup(pcName);
|
||||
return putil_strdup(pcName);
|
||||
}
|
||||
|
||||
void ptools_parse_os_path(char *path, folderPath *folders, char *delim, int mode) {
|
||||
|
|
@ -371,8 +371,8 @@ void ptools_parse_os_path(char *path, folderPath *folders, char *delim, int mode
|
|||
// In case we meet a ":" as in C:\ we set the name to Drive + the string
|
||||
// before the ":"
|
||||
fName[k] = '\0';
|
||||
buff = psync_strcat("Drive ", &fName, NULL);
|
||||
psync_strlcpy(fName, buff, strlen(buff) + 1);
|
||||
buff = putil_strcat("Drive ", &fName, NULL);
|
||||
putil_strlcpy(fName, buff, strlen(buff) + 1);
|
||||
|
||||
k = k + strlen("Drive ");
|
||||
} else {
|
||||
|
|
@ -381,7 +381,7 @@ void ptools_parse_os_path(char *path, folderPath *folders, char *delim, int mode
|
|||
}
|
||||
} else {
|
||||
fName[k] = 0;
|
||||
folders->folders[j] = psync_strdup(fName);
|
||||
folders->folders[j] = putil_strdup(fName);
|
||||
|
||||
k = 0;
|
||||
j++;
|
||||
|
|
@ -393,7 +393,7 @@ void ptools_parse_os_path(char *path, folderPath *folders, char *delim, int mode
|
|||
fName[k] = 0;
|
||||
|
||||
if (strlen(fName) > 0) {
|
||||
folders->folders[j] = psync_strdup(fName);
|
||||
folders->folders[j] = putil_strdup(fName);
|
||||
j++;
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -143,7 +143,7 @@ int64_t do_psync_file_public_link(const char *path, int64_t *plinkid,
|
|||
api = psync_apipool_get();
|
||||
if (unlikely(!api)) {
|
||||
pdbg_logf(D_WARNING, "Can't gat api from the pool. No pool ?\n");
|
||||
*err = psync_strndup("Connection error.", 17);
|
||||
*err = putil_strndup("Connection error.", 17);
|
||||
return 2;
|
||||
}
|
||||
|
||||
|
|
@ -165,7 +165,7 @@ int64_t do_psync_file_public_link(const char *path, int64_t *plinkid,
|
|||
api = psync_apipool_get();
|
||||
if (unlikely(!api)) {
|
||||
pdbg_logf(D_WARNING, "Can't gat api from the pool. No pool ?\n");
|
||||
*err = psync_strndup("Connection error.", 17);
|
||||
*err = putil_strndup("Connection error.", 17);
|
||||
free(t);
|
||||
return 1;
|
||||
}
|
||||
|
|
@ -179,13 +179,13 @@ int64_t do_psync_file_public_link(const char *path, int64_t *plinkid,
|
|||
else {
|
||||
psync_apipool_release_bad(api);
|
||||
pdbg_logf(D_WARNING, "Send command returned in valid result.\n");
|
||||
*err = psync_strndup("Connection error.", 17);
|
||||
*err = putil_strndup("Connection error.", 17);
|
||||
return 2;
|
||||
}
|
||||
result = papi_find_result2(bres, "result", PARAM_NUM)->num;
|
||||
if (unlikely(result)) {
|
||||
errorret = papi_find_result2(bres, "error", PARAM_STR)->str;
|
||||
*err = psync_strndup(errorret, strlen(errorret));
|
||||
*err = putil_strndup(errorret, strlen(errorret));
|
||||
pdbg_logf(D_WARNING, "command getfilepublink returned error code %u",
|
||||
(unsigned)result);
|
||||
psync_process_api_error(result);
|
||||
|
|
@ -194,7 +194,7 @@ int64_t do_psync_file_public_link(const char *path, int64_t *plinkid,
|
|||
}
|
||||
|
||||
rescode = papi_find_result2(bres, "link", PARAM_STR)->str;
|
||||
*link = psync_strndup(rescode, strlen(rescode));
|
||||
*link = putil_strndup(rescode, strlen(rescode));
|
||||
linkid = papi_find_result2(bres, "linkid", PARAM_NUM)->num;
|
||||
if (plinkid)
|
||||
*plinkid = linkid;
|
||||
|
|
@ -221,7 +221,7 @@ int64_t do_psync_folder_public_link(const char *path, char **link /*OUT*/,
|
|||
api = psync_apipool_get();
|
||||
if (unlikely(!api)) {
|
||||
pdbg_logf(D_WARNING, "Can't gat api from the pool. No pool ?\n");
|
||||
*err = psync_strndup("Connection error.", 17);
|
||||
*err = putil_strndup("Connection error.", 17);
|
||||
return -2;
|
||||
}
|
||||
bres = papi_send2(api, "getfolderpublink", params);
|
||||
|
|
@ -242,7 +242,7 @@ int64_t do_psync_folder_public_link(const char *path, char **link /*OUT*/,
|
|||
api = psync_apipool_get();
|
||||
if (unlikely(!api)) {
|
||||
pdbg_logf(D_WARNING, "Can't gat api from the pool. No pool ?\n");
|
||||
*err = psync_strndup("Connection error.", 17);
|
||||
*err = putil_strndup("Connection error.", 17);
|
||||
return -2;
|
||||
}
|
||||
bres = papi_send(api, "getfolderpublink",
|
||||
|
|
@ -259,19 +259,19 @@ int64_t do_psync_folder_public_link(const char *path, char **link /*OUT*/,
|
|||
result = papi_find_result2(bres, "result", PARAM_NUM)->num;
|
||||
if (unlikely(result)) {
|
||||
errorret = papi_find_result2(bres, "error", PARAM_STR)->str;
|
||||
*err = psync_strndup(errorret, strlen(errorret));
|
||||
*err = putil_strndup(errorret, strlen(errorret));
|
||||
pdbg_logf(D_WARNING, "command getfilepublink returned error code %u",
|
||||
(unsigned)result);
|
||||
psync_process_api_error(result);
|
||||
if (psync_handle_api_result(result) == PSYNC_NET_TEMPFAIL)
|
||||
return -result;
|
||||
else {
|
||||
*err = psync_strndup("Connection error.", 17);
|
||||
*err = putil_strndup("Connection error.", 17);
|
||||
return -1;
|
||||
}
|
||||
}
|
||||
rescode = papi_find_result2(bres, "link", PARAM_STR)->str;
|
||||
*link = psync_strndup(rescode, strlen(rescode));
|
||||
*link = putil_strndup(rescode, strlen(rescode));
|
||||
result = papi_find_result2(bres, "linkid", PARAM_NUM)->num;
|
||||
|
||||
free(bres);
|
||||
|
|
@ -295,7 +295,7 @@ int64_t do_psync_folder_public_link_full(const char *path, char **link /*OUT*/,
|
|||
api = psync_apipool_get();
|
||||
if (unlikely(!api)) {
|
||||
pdbg_logf(D_WARNING, "Can't gat api from the pool. No pool ?\n");
|
||||
*err = psync_strndup("Connection error.", 17);
|
||||
*err = putil_strndup("Connection error.", 17);
|
||||
return -2;
|
||||
}
|
||||
bres = papi_send2(api, "getfolderpublink", params);
|
||||
|
|
@ -318,7 +318,7 @@ int64_t do_psync_folder_public_link_full(const char *path, char **link /*OUT*/,
|
|||
api = psync_apipool_get();
|
||||
if (unlikely(!api)) {
|
||||
pdbg_logf(D_WARNING, "Can't gat api from the pool. No pool ?\n");
|
||||
*err = psync_strndup("Connection error.", 17);
|
||||
*err = putil_strndup("Connection error.", 17);
|
||||
return -2;
|
||||
}
|
||||
bres = papi_send(api, "getfolderpublink",
|
||||
|
|
@ -336,20 +336,20 @@ int64_t do_psync_folder_public_link_full(const char *path, char **link /*OUT*/,
|
|||
result = papi_find_result2(bres, "result", PARAM_NUM)->num;
|
||||
if (unlikely(result)) {
|
||||
errorret = papi_find_result2(bres, "error", PARAM_STR)->str;
|
||||
*err = psync_strndup(errorret, strlen(errorret));
|
||||
*err = putil_strndup(errorret, strlen(errorret));
|
||||
pdbg_logf(D_WARNING, "command getfilepublink returned error code %u",
|
||||
(unsigned)result);
|
||||
psync_process_api_error(result);
|
||||
if (psync_handle_api_result(result) == PSYNC_NET_TEMPFAIL)
|
||||
return -result;
|
||||
else {
|
||||
*err = psync_strndup("Connection error.", 17);
|
||||
*err = putil_strndup("Connection error.", 17);
|
||||
return -1;
|
||||
}
|
||||
}
|
||||
|
||||
rescode = papi_find_result2(bres, "link", PARAM_STR)->str;
|
||||
*link = psync_strndup(rescode, strlen(rescode));
|
||||
*link = putil_strndup(rescode, strlen(rescode));
|
||||
result = papi_find_result2(bres, "linkid", PARAM_NUM)->num;
|
||||
|
||||
free(bres);
|
||||
|
|
@ -371,7 +371,7 @@ int64_t do_psync_folder_updownlink_link(int canupload,
|
|||
api = psync_apipool_get();
|
||||
if (unlikely(!api)) {
|
||||
pdbg_logf(D_WARNING, "Can't get api from the pool. No pool ?\n");
|
||||
*err = psync_strndup("Connection error.", 17);
|
||||
*err = putil_strndup("Connection error.", 17);
|
||||
return -2;
|
||||
}
|
||||
bres = papi_send2(api, "publink/createfolderlinkandsend", params);
|
||||
|
|
@ -386,7 +386,7 @@ int64_t do_psync_folder_updownlink_link(int canupload,
|
|||
result = papi_find_result2(bres, "result", PARAM_NUM)->num;
|
||||
if (unlikely(result)) {
|
||||
errorret = papi_find_result2(bres, "error", PARAM_STR)->str;
|
||||
*err = psync_strndup(errorret, strlen(errorret));
|
||||
*err = putil_strndup(errorret, strlen(errorret));
|
||||
pdbg_logf(D_WARNING,
|
||||
"command createfolderlinkwithuploadandsend returned error code %u",
|
||||
(unsigned)result);
|
||||
|
|
@ -394,7 +394,7 @@ int64_t do_psync_folder_updownlink_link(int canupload,
|
|||
if (psync_handle_api_result(result) == PSYNC_NET_TEMPFAIL)
|
||||
return -result;
|
||||
else {
|
||||
*err = psync_strndup("Connection error.", 17);
|
||||
*err = putil_strndup("Connection error.", 17);
|
||||
return -1;
|
||||
}
|
||||
}
|
||||
|
|
@ -439,7 +439,7 @@ int64_t do_ptree_public_link(const char *linkname, const char *root,
|
|||
|
||||
if (root) {
|
||||
ids = (char *)malloc(FOLDERID_ENTRY_SIZE);
|
||||
id = psync_fsfolderid_by_path(root, 0);
|
||||
id = pfs_fldr_id_by_path(root, 0);
|
||||
k = sprintf(ids, "%lld", (long long)id);
|
||||
init_param_str(t + pind++, "folderid", ids);
|
||||
}
|
||||
|
|
@ -448,7 +448,7 @@ int64_t do_ptree_public_link(const char *linkname, const char *root,
|
|||
ids1 = (char *)malloc(numfolders * FOLDERID_ENTRY_SIZE);
|
||||
idsp = ids1;
|
||||
for (i = 0; i < numfolders; ++i) {
|
||||
id = psync_fsfolderid_by_path(folders[i], 0);
|
||||
id = pfs_fldr_id_by_path(folders[i], 0);
|
||||
k = sprintf(idsp, "%lld", (long long)id);
|
||||
if (unlikely(k <= 0))
|
||||
break;
|
||||
|
|
@ -469,7 +469,7 @@ int64_t do_ptree_public_link(const char *linkname, const char *root,
|
|||
idsp = ids2;
|
||||
for (i = 0; i < numfiles; ++i) {
|
||||
psql_rdlock();
|
||||
filep = psync_fsfolder_resolve_path(files[i]);
|
||||
filep = pfs_fldr_resolve_path(files[i]);
|
||||
if (filep) {
|
||||
res = psql_query_nolock("select id from file where parentfolderid "
|
||||
"= ? and name = ? limit 1");
|
||||
|
|
@ -507,7 +507,7 @@ int64_t do_ptree_public_link(const char *linkname, const char *root,
|
|||
api = psync_apipool_get();
|
||||
if (unlikely(!api)) {
|
||||
pdbg_logf(D_WARNING, "Can't gat api from the pool. No pool ?\n");
|
||||
*err = psync_strndup("Connection error.", 17);
|
||||
*err = putil_strndup("Connection error.", 17);
|
||||
return -2;
|
||||
}
|
||||
|
||||
|
|
@ -519,26 +519,26 @@ int64_t do_ptree_public_link(const char *linkname, const char *root,
|
|||
else {
|
||||
psync_apipool_release_bad(api);
|
||||
pdbg_logf(D_WARNING, "Send command returned in valid result.\n");
|
||||
*err = psync_strndup("Connection error.", 17);
|
||||
*err = putil_strndup("Connection error.", 17);
|
||||
return -2;
|
||||
}
|
||||
result = papi_find_result2(bres, "result", PARAM_NUM)->num;
|
||||
if (unlikely(result)) {
|
||||
errorret = papi_find_result2(bres, "error", PARAM_STR)->str;
|
||||
*err = psync_strndup(errorret, strlen(errorret));
|
||||
*err = putil_strndup(errorret, strlen(errorret));
|
||||
pdbg_logf(D_WARNING, "command gettreepublink returned error code %u",
|
||||
(unsigned)result);
|
||||
psync_process_api_error(result);
|
||||
if (psync_handle_api_result(result) == PSYNC_NET_TEMPFAIL)
|
||||
return -result;
|
||||
else {
|
||||
*err = psync_strndup("Connection error.", 17);
|
||||
*err = putil_strndup("Connection error.", 17);
|
||||
return -1;
|
||||
}
|
||||
}
|
||||
|
||||
rescode = papi_find_result2(bres, "link", PARAM_STR)->str;
|
||||
*link = psync_strndup(rescode, strlen(rescode));
|
||||
*link = putil_strndup(rescode, strlen(rescode));
|
||||
|
||||
result = papi_find_result2(bres, "linkid", PARAM_NUM)->num;
|
||||
|
||||
|
|
@ -575,7 +575,7 @@ int cache_links(char *err, size_t err_size /*OUT*/) {
|
|||
api = psync_apipool_get();
|
||||
if (unlikely(!api)) {
|
||||
pdbg_logf(D_WARNING, "Can't gat api from the pool. No pool ?\n");
|
||||
//*err = psync_strndup("Connection error.", 17);
|
||||
//*err = putil_strndup("Connection error.", 17);
|
||||
snprintf(err, err_size, "Connection error.");
|
||||
return -2;
|
||||
}
|
||||
|
|
@ -588,7 +588,7 @@ int cache_links(char *err, size_t err_size /*OUT*/) {
|
|||
api = psync_apipool_get();
|
||||
if (unlikely(!api)) {
|
||||
pdbg_logf(D_WARNING, "Can't gat api from the pool. No pool ?\n");
|
||||
//*err = psync_strndup("Connection error.", 17);
|
||||
//*err = putil_strndup("Connection error.", 17);
|
||||
snprintf(err, err_size, "Connection error.");
|
||||
return -2;
|
||||
}
|
||||
|
|
@ -602,7 +602,7 @@ int cache_links(char *err, size_t err_size /*OUT*/) {
|
|||
else {
|
||||
psync_apipool_release_bad(api);
|
||||
pdbg_logf(D_WARNING, "Send command returned in valid result.\n");
|
||||
//*err = psync_strndup("Connection error.", 17);
|
||||
//*err = putil_strndup("Connection error.", 17);
|
||||
snprintf(err, err_size, "Connection error.");
|
||||
free(bres);
|
||||
return 0;
|
||||
|
|
@ -610,7 +610,7 @@ int cache_links(char *err, size_t err_size /*OUT*/) {
|
|||
result = papi_find_result2(bres, "result", PARAM_NUM)->num;
|
||||
if (unlikely(result)) {
|
||||
errorret = papi_find_result2(bres, "error", PARAM_STR)->str;
|
||||
//*err = psync_strndup(errorret, strlen(errorret));
|
||||
//*err = putil_strndup(errorret, strlen(errorret));
|
||||
snprintf(err, err_size, "%s", errorret);
|
||||
pdbg_logf(D_WARNING, "command listpublinks returned error code %u",
|
||||
(unsigned)result);
|
||||
|
|
@ -619,7 +619,7 @@ int cache_links(char *err, size_t err_size /*OUT*/) {
|
|||
if (psync_handle_api_result(result) == PSYNC_NET_TEMPFAIL)
|
||||
return -result;
|
||||
else {
|
||||
//*err = psync_strndup("Connection error.", 17);
|
||||
//*err = putil_strndup("Connection error.", 17);
|
||||
snprintf(err, err_size, "Connection error.");
|
||||
return 0;
|
||||
}
|
||||
|
|
@ -725,7 +725,7 @@ int do_psync_delete_link(int64_t linkid, char **err /*OUT*/) {
|
|||
api = psync_apipool_get();
|
||||
if (unlikely(!api)) {
|
||||
pdbg_logf(D_WARNING, "Can't gat api from the pool. No pool ?\n");
|
||||
*err = psync_strndup("Connection error.", 17);
|
||||
*err = putil_strndup("Connection error.", 17);
|
||||
return -2;
|
||||
}
|
||||
bres = papi_send2(api, "deletepublink", params);
|
||||
|
|
@ -735,20 +735,20 @@ int do_psync_delete_link(int64_t linkid, char **err /*OUT*/) {
|
|||
else {
|
||||
psync_apipool_release_bad(api);
|
||||
pdbg_logf(D_WARNING, "Send command returned in valid result.\n");
|
||||
*err = psync_strndup("Connection error.", 17);
|
||||
*err = putil_strndup("Connection error.", 17);
|
||||
return -2;
|
||||
}
|
||||
result = papi_find_result2(bres, "result", PARAM_NUM)->num;
|
||||
if (unlikely(result)) {
|
||||
errorret = papi_find_result2(bres, "error", PARAM_STR)->str;
|
||||
*err = psync_strndup(errorret, strlen(errorret));
|
||||
*err = putil_strndup(errorret, strlen(errorret));
|
||||
pdbg_logf(D_WARNING, "command deletepublink returned error code %u",
|
||||
(unsigned)result);
|
||||
psync_process_api_error(result);
|
||||
if (psync_handle_api_result(result) == PSYNC_NET_TEMPFAIL)
|
||||
return -result;
|
||||
else {
|
||||
*err = psync_strndup("Connection error.", 17);
|
||||
*err = putil_strndup("Connection error.", 17);
|
||||
return -1;
|
||||
}
|
||||
}
|
||||
|
|
@ -765,20 +765,20 @@ int process_bres(const char *cmd, binresult *bres, psock_t *api,
|
|||
else {
|
||||
psync_apipool_release_bad(api);
|
||||
pdbg_logf(D_WARNING, "Send command returned in valid result.\n");
|
||||
*err = psync_strndup("Connection error.", 17);
|
||||
*err = putil_strndup("Connection error.", 17);
|
||||
return -2;
|
||||
}
|
||||
result = papi_find_result2(bres, "result", PARAM_NUM)->num;
|
||||
if (unlikely(result)) {
|
||||
errorret = papi_find_result2(bres, "error", PARAM_STR)->str;
|
||||
*err = psync_strndup(errorret, strlen(errorret));
|
||||
*err = putil_strndup(errorret, strlen(errorret));
|
||||
pdbg_logf(D_WARNING, "command %s returned error code %u", cmd,
|
||||
(unsigned)result);
|
||||
psync_process_api_error(result);
|
||||
if (psync_handle_api_result(result) == PSYNC_NET_TEMPFAIL)
|
||||
return -result;
|
||||
else {
|
||||
*err = psync_strndup("Connection error.", 17);
|
||||
*err = putil_strndup("Connection error.", 17);
|
||||
return -1;
|
||||
}
|
||||
}
|
||||
|
|
@ -827,7 +827,7 @@ int do_psync_change_link(unsigned long long linkid, unsigned long long expire,
|
|||
api = psync_apipool_get();
|
||||
if (unlikely(!api)) {
|
||||
pdbg_logf(D_WARNING, "Can't get api from the pool. No pool ?\n");
|
||||
*err = psync_strndup("Connection error.", 17);
|
||||
*err = putil_strndup("Connection error.", 17);
|
||||
return -2;
|
||||
}
|
||||
bres = papi_send(api, "changepublink", sizeof("changepublink") - 1, t,
|
||||
|
|
@ -847,7 +847,7 @@ int do_change_link_expire(unsigned long long linkid, unsigned long long expire,
|
|||
api = psync_apipool_get();
|
||||
if (unlikely(!api)) {
|
||||
pdbg_logf(D_WARNING, "Can't gat api from the pool. No pool ?\n");
|
||||
*err = psync_strndup("Connection error.", 17);
|
||||
*err = putil_strndup("Connection error.", 17);
|
||||
return -2;
|
||||
}
|
||||
|
||||
|
|
@ -877,7 +877,7 @@ int do_change_link_password(unsigned long long linkid, const char *password,
|
|||
api = psync_apipool_get();
|
||||
if (unlikely(!api)) {
|
||||
pdbg_logf(D_WARNING, "Can't gat api from the pool. No pool ?\n");
|
||||
*err = psync_strndup("Connection error.", 17);
|
||||
*err = putil_strndup("Connection error.", 17);
|
||||
return -2;
|
||||
}
|
||||
|
||||
|
|
@ -906,7 +906,7 @@ int do_change_link_enable_upload(unsigned long long linkid,
|
|||
api = psync_apipool_get();
|
||||
if (unlikely(!api)) {
|
||||
pdbg_logf(D_WARNING, "Can't gat api from the pool. No pool ?\n");
|
||||
*err = psync_strndup("Connection error.", 17);
|
||||
*err = putil_strndup("Connection error.", 17);
|
||||
return -2;
|
||||
}
|
||||
if (enableuploadforeveryone || enableuploadforchosenusers) {
|
||||
|
|
@ -945,7 +945,7 @@ int64_t do_psync_upload_link(const char *path, const char *comment,
|
|||
api = psync_apipool_get();
|
||||
if (unlikely(!api)) {
|
||||
pdbg_logf(D_WARNING, "Can't gat api from the pool. No pool ?\n");
|
||||
*err = psync_strndup("Connection error.", 17);
|
||||
*err = putil_strndup("Connection error.", 17);
|
||||
return -2;
|
||||
}
|
||||
|
||||
|
|
@ -969,7 +969,7 @@ int64_t do_psync_upload_link(const char *path, const char *comment,
|
|||
api = psync_apipool_get();
|
||||
if (unlikely(!api)) {
|
||||
pdbg_logf(D_WARNING, "Can't gat api from the pool. No pool ?\n");
|
||||
*err = psync_strndup("Connection error.", 17);
|
||||
*err = putil_strndup("Connection error.", 17);
|
||||
return -2;
|
||||
}
|
||||
bres = papi_send(api, "createuploadlink",
|
||||
|
|
@ -982,26 +982,26 @@ int64_t do_psync_upload_link(const char *path, const char *comment,
|
|||
else {
|
||||
psync_apipool_release_bad(api);
|
||||
pdbg_logf(D_WARNING, "Send command returned in valid result.\n");
|
||||
*err = psync_strndup("Connection error.", 17);
|
||||
*err = putil_strndup("Connection error.", 17);
|
||||
return -2;
|
||||
}
|
||||
result = papi_find_result2(bres, "result", PARAM_NUM)->num;
|
||||
if (unlikely(result)) {
|
||||
errorret = papi_find_result2(bres, "error", PARAM_STR)->str;
|
||||
*err = psync_strndup(errorret, strlen(errorret));
|
||||
*err = putil_strndup(errorret, strlen(errorret));
|
||||
pdbg_logf(D_WARNING, "command createuploadlink returned error code %u",
|
||||
(unsigned)result);
|
||||
psync_process_api_error(result);
|
||||
if (psync_handle_api_result(result) == PSYNC_NET_TEMPFAIL)
|
||||
return -result;
|
||||
else {
|
||||
*err = psync_strndup("Connection error.", 17);
|
||||
*err = putil_strndup("Connection error.", 17);
|
||||
return -1;
|
||||
}
|
||||
}
|
||||
|
||||
rescode = papi_find_result2(bres, "link", PARAM_STR)->str;
|
||||
*link = psync_strndup(rescode, strlen(rescode));
|
||||
*link = putil_strndup(rescode, strlen(rescode));
|
||||
|
||||
result = papi_find_result2(bres, "uploadlinkid", PARAM_NUM)->num;
|
||||
|
||||
|
|
@ -1022,7 +1022,7 @@ int do_psync_delete_upload_link(int64_t uploadlinkid, char **err /*OUT*/) {
|
|||
api = psync_apipool_get();
|
||||
if (unlikely(!api)) {
|
||||
pdbg_logf(D_WARNING, "Can't gat api from the pool. No pool ?\n");
|
||||
*err = psync_strndup("Connection error.", 17);
|
||||
*err = putil_strndup("Connection error.", 17);
|
||||
return -2;
|
||||
}
|
||||
|
||||
|
|
@ -1126,7 +1126,7 @@ plink_contents_t *do_show_link(const char *code, char **err /*OUT*/) {
|
|||
api = psync_apipool_get();
|
||||
if (unlikely(!api)) {
|
||||
pdbg_logf(D_WARNING, "Can't gat api from the pool. No pool ?\n");
|
||||
*err = psync_strndup("Can't gat api from the pool.", 29);
|
||||
*err = putil_strndup("Can't gat api from the pool.", 29);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
|
|
@ -1137,7 +1137,7 @@ plink_contents_t *do_show_link(const char *code, char **err /*OUT*/) {
|
|||
else {
|
||||
psync_apipool_release_bad(api);
|
||||
pdbg_logf(D_WARNING, "Send command returned in valid result.\n");
|
||||
*err = psync_strndup("Connection error.", 17);
|
||||
*err = putil_strndup("Connection error.", 17);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
|
|
@ -1204,7 +1204,7 @@ int cache_upload_links(char **err /*OUT*/) {
|
|||
api = psync_apipool_get();
|
||||
if (unlikely(!api)) {
|
||||
pdbg_logf(D_WARNING, "Can't gat api from the pool. No pool ?\n");
|
||||
*err = psync_strndup("Connection error.", 17);
|
||||
*err = putil_strndup("Connection error.", 17);
|
||||
return -2;
|
||||
}
|
||||
bres = papi_send2(api, "listuploadlinks", params);
|
||||
|
|
@ -1215,7 +1215,7 @@ int cache_upload_links(char **err /*OUT*/) {
|
|||
api = psync_apipool_get();
|
||||
if (unlikely(!api)) {
|
||||
pdbg_logf(D_WARNING, "Can't gat api from the pool. No pool ?\n");
|
||||
*err = psync_strndup("Connection error.", 17);
|
||||
*err = putil_strndup("Connection error.", 17);
|
||||
return -2;
|
||||
}
|
||||
bres = papi_send2(api, "listuploadlinks", params);
|
||||
|
|
@ -1226,20 +1226,20 @@ int cache_upload_links(char **err /*OUT*/) {
|
|||
else {
|
||||
psync_apipool_release_bad(api);
|
||||
pdbg_logf(D_WARNING, "Send command returned in valid result.\n");
|
||||
*err = psync_strndup("Connection error.", 17);
|
||||
*err = putil_strndup("Connection error.", 17);
|
||||
return -2;
|
||||
}
|
||||
result = papi_find_result2(bres, "result", PARAM_NUM)->num;
|
||||
if (unlikely(result)) {
|
||||
errorret = papi_find_result2(bres, "error", PARAM_STR)->str;
|
||||
*err = psync_strndup(errorret, strlen(errorret));
|
||||
*err = putil_strndup(errorret, strlen(errorret));
|
||||
pdbg_logf(D_WARNING, "command listpublinks returned error code %u",
|
||||
(unsigned)result);
|
||||
psync_process_api_error(result);
|
||||
if (psync_handle_api_result(result) == PSYNC_NET_TEMPFAIL)
|
||||
return -result;
|
||||
else {
|
||||
*err = psync_strndup("Connection error.", 17);
|
||||
*err = putil_strndup("Connection error.", 17);
|
||||
return -1;
|
||||
}
|
||||
}
|
||||
|
|
@ -1415,7 +1415,7 @@ preciever_list_t *do_list_email_with_access(unsigned long long linkid,
|
|||
api = psync_apipool_get();
|
||||
if (unlikely(!api)) {
|
||||
pdbg_logf(D_WARNING, "Can't gat api from the pool. No pool ?\n");
|
||||
*err = psync_strndup("Connection error.", 17);
|
||||
*err = putil_strndup("Connection error.", 17);
|
||||
return NULL;
|
||||
}
|
||||
bres = papi_send2(api, "publink/listemailswithaccess", params);
|
||||
|
|
@ -1424,20 +1424,20 @@ preciever_list_t *do_list_email_with_access(unsigned long long linkid,
|
|||
else {
|
||||
psync_apipool_release_bad(api);
|
||||
pdbg_logf(D_WARNING, "Send command returned in valid result.\n");
|
||||
*err = psync_strndup("Connection error.", 17);
|
||||
*err = putil_strndup("Connection error.", 17);
|
||||
return NULL;
|
||||
}
|
||||
result = papi_find_result2(bres, "result", PARAM_NUM)->num;
|
||||
if (unlikely(result)) {
|
||||
errorret = papi_find_result2(bres, "error", PARAM_STR)->str;
|
||||
*err = psync_strndup(errorret, strlen(errorret));
|
||||
*err = putil_strndup(errorret, strlen(errorret));
|
||||
pdbg_logf(D_WARNING, "command listemailswithaccess returned error code %u",
|
||||
(unsigned)result);
|
||||
psync_process_api_error(result);
|
||||
if (psync_handle_api_result(result) == PSYNC_NET_TEMPFAIL)
|
||||
return NULL;
|
||||
else {
|
||||
*err = psync_strndup("Connection error.", 17);
|
||||
*err = putil_strndup("Connection error.", 17);
|
||||
return NULL;
|
||||
}
|
||||
}
|
||||
|
|
@ -1484,7 +1484,7 @@ int do_link_add_access(unsigned long long linkid, const char *mail,
|
|||
api = psync_apipool_get();
|
||||
if (unlikely(!api)) {
|
||||
pdbg_logf(D_WARNING, "Can't gat api from the pool. No pool ?\n");
|
||||
*err = psync_strndup("Connection error.", 17);
|
||||
*err = putil_strndup("Connection error.", 17);
|
||||
return -2;
|
||||
}
|
||||
|
||||
|
|
@ -1507,7 +1507,7 @@ int do_link_remove_access(unsigned long long linkid,
|
|||
api = psync_apipool_get();
|
||||
if (unlikely(!api)) {
|
||||
pdbg_logf(D_WARNING, "Can't gat api from the pool. No pool ?\n");
|
||||
*err = psync_strndup("Connection error.", 17);
|
||||
*err = putil_strndup("Connection error.", 17);
|
||||
return -2;
|
||||
}
|
||||
|
||||
|
|
@ -1534,7 +1534,7 @@ bookmarks_list_t *do_cache_bookmarks(char **err) {
|
|||
api = psync_apipool_get();
|
||||
if (unlikely(!api)) {
|
||||
pdbg_logf(D_WARNING, "Can't gat api from the pool. No pool ?\n");
|
||||
*err = psync_strndup("Connection error.", 17);
|
||||
*err = putil_strndup("Connection error.", 17);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
|
|
@ -1545,20 +1545,20 @@ bookmarks_list_t *do_cache_bookmarks(char **err) {
|
|||
else {
|
||||
psync_apipool_release_bad(api);
|
||||
pdbg_logf(D_WARNING, "Send command returned in valid result.\n");
|
||||
*err = psync_strndup("Connection error.", 17);
|
||||
*err = putil_strndup("Connection error.", 17);
|
||||
return NULL;
|
||||
}
|
||||
result = papi_find_result2(bres, "result", PARAM_NUM)->num;
|
||||
if (unlikely(result)) {
|
||||
errorret = papi_find_result2(bres, "error", PARAM_STR)->str;
|
||||
*err = psync_strndup(errorret, strlen(errorret));
|
||||
*err = putil_strndup(errorret, strlen(errorret));
|
||||
pdbg_logf(D_WARNING, "command deletepublink returned error code %u",
|
||||
(unsigned)result);
|
||||
psync_process_api_error(result);
|
||||
if (psync_handle_api_result(result) == PSYNC_NET_TEMPFAIL)
|
||||
return NULL;
|
||||
else {
|
||||
*err = psync_strndup("Connection error.", 17);
|
||||
*err = putil_strndup("Connection error.", 17);
|
||||
return NULL;
|
||||
}
|
||||
}
|
||||
|
|
@ -1618,7 +1618,7 @@ int do_remove_bookmark(const char *code, int locationid, char **err) {
|
|||
api = psync_apipool_get();
|
||||
if (unlikely(!api)) {
|
||||
pdbg_logf(D_WARNING, "Can't gat api from the pool. No pool ?\n");
|
||||
*err = psync_strndup("Connection error.", 17);
|
||||
*err = putil_strndup("Connection error.", 17);
|
||||
return -2;
|
||||
}
|
||||
|
||||
|
|
@ -1643,7 +1643,7 @@ int do_change_bookmark(const char *code, int locationid, const char *name,
|
|||
api = psync_apipool_get();
|
||||
if (unlikely(!api)) {
|
||||
pdbg_logf(D_WARNING, "Can't gat api from the pool. No pool ?\n");
|
||||
*err = psync_strndup("Connection error.", 17);
|
||||
*err = putil_strndup("Connection error.", 17);
|
||||
return -2;
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -1067,7 +1067,7 @@ static int upload_big_file(const char *localpath, const unsigned char *hashhex,
|
|||
sql = psql_query_rdlock("SELECT name FROM localfile WHERE id=?");
|
||||
psql_bind_uint(sql, 1, localfileid);
|
||||
if ((srow = psql_fetch_str(sql))) {
|
||||
char *nname = psync_strdup(srow[0]);
|
||||
char *nname = putil_strdup(srow[0]);
|
||||
psql_free(sql);
|
||||
pdbg_logf(D_NOTICE, "looking for folderid=%lu and name=%s in file",
|
||||
(unsigned long)folderid, nname);
|
||||
|
|
@ -1463,7 +1463,7 @@ static int task_uploadfile(psync_syncid_t syncid, psync_folderid_t localfileid,
|
|||
}
|
||||
if (*s1 == *s2) { //==0
|
||||
pdbg_logf(D_NOTICE, "uploading %s as %s", name, srow[0]);
|
||||
nname = psync_strdup(srow[0]);
|
||||
nname = putil_strdup(srow[0]);
|
||||
name = nname;
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -14,7 +14,7 @@
|
|||
|
||||
static char normalize_table[256];
|
||||
|
||||
const char base64_table[] = {
|
||||
const char putil_base64_table[] = {
|
||||
'A', 'B', 'C', 'D', 'E', 'F', 'G', 'H', 'I', 'J', 'K', 'L', 'M',
|
||||
'N', 'O', 'P', 'Q', 'R', 'S', 'T', 'U', 'V', 'W', 'X', 'Y', 'Z',
|
||||
'a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i', 'j', 'k', 'l', 'm',
|
||||
|
|
@ -73,7 +73,7 @@ void putil_wipe(void *mem, size_t sz) {
|
|||
}
|
||||
}
|
||||
|
||||
void time_format(time_t tm, unsigned long ns, char *result) {
|
||||
void putil_time_format(time_t tm, unsigned long ns, char *result) {
|
||||
static const char month_names[12][4] = {"Jan", "Feb", "Mar", "Apr",
|
||||
"May", "Jun", "Jul", "Aug",
|
||||
"Sep", "Oct", "Nov", "Dec"};
|
||||
|
|
@ -117,13 +117,13 @@ void time_format(time_t tm, unsigned long ns, char *result) {
|
|||
memcpy(result, " +0000", 7); // copies the null byte
|
||||
}
|
||||
|
||||
char *psync_strdup(const char *str) {
|
||||
char *putil_strdup(const char *str) {
|
||||
size_t len;
|
||||
len = strlen(str) + 1;
|
||||
return (char *)memcpy(malloc(sizeof(char) * len), str, len);
|
||||
}
|
||||
|
||||
char *psync_strnormalize_filename(const char *str) {
|
||||
char *putil_strnormalize_filename(const char *str) {
|
||||
size_t len, i;
|
||||
char *ptr;
|
||||
len = strlen(str) + 1;
|
||||
|
|
@ -133,14 +133,14 @@ char *psync_strnormalize_filename(const char *str) {
|
|||
return ptr;
|
||||
}
|
||||
|
||||
char *psync_strndup(const char *str, size_t len) {
|
||||
char *putil_strndup(const char *str, size_t len) {
|
||||
char *ptr;
|
||||
ptr = (char *)memcpy(malloc(sizeof(char) * len + 1), str, len);
|
||||
ptr[len] = 0;
|
||||
return ptr;
|
||||
}
|
||||
|
||||
char *psync_strcat(const char *str, ...) {
|
||||
char *putil_strcat(const char *str, ...) {
|
||||
size_t i, size, len;
|
||||
const char *strs[64];
|
||||
size_t lengths[64];
|
||||
|
|
@ -170,7 +170,7 @@ char *psync_strcat(const char *str, ...) {
|
|||
return ptr3;
|
||||
}
|
||||
|
||||
int psync_slprintf(char *str, size_t size, const char *format, ...) {
|
||||
int putil_slprintf(char *str, size_t size, const char *format, ...) {
|
||||
va_list ap;
|
||||
int ret;
|
||||
va_start(ap, format);
|
||||
|
|
@ -181,7 +181,7 @@ int psync_slprintf(char *str, size_t size, const char *format, ...) {
|
|||
return ret;
|
||||
}
|
||||
|
||||
unsigned char *psync_base32_encode(const unsigned char *str, size_t length,
|
||||
unsigned char *putil_base32_encode(const unsigned char *str, size_t length,
|
||||
size_t *ret_length) {
|
||||
static const unsigned char *table =
|
||||
(const unsigned char *)"ABCDEFGHIJKLMNOPQRSTUVWXYZ234567";
|
||||
|
|
@ -220,7 +220,7 @@ unsigned char *psync_base32_encode(const unsigned char *str, size_t length,
|
|||
return result;
|
||||
}
|
||||
|
||||
unsigned char *psync_base32_decode(const unsigned char *str, size_t length,
|
||||
unsigned char *putil_base32_decode(const unsigned char *str, size_t length,
|
||||
size_t *ret_length) {
|
||||
unsigned char *result, *p;
|
||||
uint32_t bits, buff;
|
||||
|
|
@ -252,7 +252,7 @@ unsigned char *psync_base32_decode(const unsigned char *str, size_t length,
|
|||
return result;
|
||||
}
|
||||
|
||||
unsigned char *psync_base64_encode(const unsigned char *str, size_t length,
|
||||
unsigned char *putil_base64_encode(const unsigned char *str, size_t length,
|
||||
size_t *ret_length) {
|
||||
const unsigned char *current = str;
|
||||
unsigned char *p;
|
||||
|
|
@ -262,22 +262,22 @@ unsigned char *psync_base64_encode(const unsigned char *str, size_t length,
|
|||
p = result;
|
||||
|
||||
while (length > 2) {
|
||||
*p++ = base64_table[current[0] >> 2];
|
||||
*p++ = base64_table[((current[0] & 0x03) << 4) + (current[1] >> 4)];
|
||||
*p++ = base64_table[((current[1] & 0x0f) << 2) + (current[2] >> 6)];
|
||||
*p++ = base64_table[current[2] & 0x3f];
|
||||
*p++ = putil_base64_table[current[0] >> 2];
|
||||
*p++ = putil_base64_table[((current[0] & 0x03) << 4) + (current[1] >> 4)];
|
||||
*p++ = putil_base64_table[((current[1] & 0x0f) << 2) + (current[2] >> 6)];
|
||||
*p++ = putil_base64_table[current[2] & 0x3f];
|
||||
current += 3;
|
||||
length -= 3;
|
||||
}
|
||||
|
||||
if (length != 0) {
|
||||
*p++ = base64_table[current[0] >> 2];
|
||||
*p++ = putil_base64_table[current[0] >> 2];
|
||||
if (length > 1) {
|
||||
*p++ = base64_table[((current[0] & 0x03) << 4) + (current[1] >> 4)];
|
||||
*p++ = base64_table[(current[1] & 0x0f) << 2];
|
||||
*p++ = putil_base64_table[((current[0] & 0x03) << 4) + (current[1] >> 4)];
|
||||
*p++ = putil_base64_table[(current[1] & 0x0f) << 2];
|
||||
*p++ = '='; /* Add padding */
|
||||
} else {
|
||||
*p++ = base64_table[(current[0] & 0x03) << 4];
|
||||
*p++ = putil_base64_table[(current[0] & 0x03) << 4];
|
||||
*p++ = '='; /* Add padding */
|
||||
*p++ = '='; /* Add padding */
|
||||
}
|
||||
|
|
@ -288,7 +288,7 @@ unsigned char *psync_base64_encode(const unsigned char *str, size_t length,
|
|||
return result;
|
||||
}
|
||||
|
||||
unsigned char *psync_base64_decode(const unsigned char *str, size_t length,
|
||||
unsigned char *putil_base64_decode(const unsigned char *str, size_t length,
|
||||
size_t *ret_length) {
|
||||
const unsigned char *current = str;
|
||||
unsigned char *result;
|
||||
|
|
@ -328,7 +328,7 @@ unsigned char *psync_base64_decode(const unsigned char *str, size_t length,
|
|||
return result;
|
||||
}
|
||||
|
||||
int psync_is_valid_utf8(const char *str) {
|
||||
int putil_is_valid_utf8(const char *str) {
|
||||
static const int8_t trailing[] = {
|
||||
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
|
||||
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
|
||||
|
|
@ -359,14 +359,14 @@ int psync_is_valid_utf8(const char *str) {
|
|||
return 1;
|
||||
}
|
||||
|
||||
uint64_t psync_ato64(const char *str) {
|
||||
uint64_t putil_ato64(const char *str) {
|
||||
uint64_t n = 0;
|
||||
while (*str >= '0' && *str <= '9')
|
||||
n = n * 10 + (*str++) - '0';
|
||||
return n;
|
||||
}
|
||||
|
||||
uint32_t psync_ato32(const char *str) {
|
||||
uint32_t putil_ato32(const char *str) {
|
||||
uint32_t n = 0;
|
||||
while (*str >= '0' && *str <= '9')
|
||||
n = n * 10 + (*str++) - '0';
|
||||
|
|
|
|||
|
|
@ -24,24 +24,24 @@ extern "C" {
|
|||
return PSYNC_INVALID_SYNCID; \
|
||||
} while (0)
|
||||
|
||||
extern const char base64_table[];
|
||||
extern const char putil_base64_table[];
|
||||
|
||||
void putil_wipe(void *mem, size_t sz);
|
||||
void time_format(time_t tm, unsigned long ns, char *result);
|
||||
char *psync_strdup(const char *str) PSYNC_MALLOC PSYNC_NONNULL(1);
|
||||
char *psync_strnormalize_filename(const char *str) PSYNC_MALLOC PSYNC_NONNULL(1);
|
||||
char *psync_strndup(const char *str, size_t len) PSYNC_MALLOC PSYNC_NONNULL(1);
|
||||
char *psync_strcat(const char *str, ...) PSYNC_MALLOC PSYNC_SENTINEL;
|
||||
int psync_slprintf(char *str, size_t size, const char *format, ...) PSYNC_NONNULL(1, 3);
|
||||
unsigned char *psync_base32_encode(const unsigned char *str, size_t length, size_t *ret_length);
|
||||
unsigned char *psync_base32_decode(const unsigned char *str, size_t length, size_t *ret_length);
|
||||
unsigned char *psync_base64_encode(const unsigned char *str, size_t length, size_t *ret_length);
|
||||
unsigned char *psync_base64_decode(const unsigned char *str, size_t length, size_t *ret_length);
|
||||
int psync_is_valid_utf8(const char *str);
|
||||
uint64_t psync_ato64(const char *str);
|
||||
uint32_t psync_ato32(const char *str);
|
||||
void putil_time_format(time_t tm, unsigned long ns, char *result);
|
||||
char *putil_strdup(const char *str) PSYNC_MALLOC PSYNC_NONNULL(1);
|
||||
char *putil_strnormalize_filename(const char *str) PSYNC_MALLOC PSYNC_NONNULL(1);
|
||||
char *putil_strndup(const char *str, size_t len) PSYNC_MALLOC PSYNC_NONNULL(1);
|
||||
char *putil_strcat(const char *str, ...) PSYNC_MALLOC PSYNC_SENTINEL;
|
||||
int putil_slprintf(char *str, size_t size, const char *format, ...) PSYNC_NONNULL(1, 3);
|
||||
unsigned char *putil_base32_encode(const unsigned char *str, size_t length, size_t *ret_length);
|
||||
unsigned char *putil_base32_decode(const unsigned char *str, size_t length, size_t *ret_length);
|
||||
unsigned char *putil_base64_encode(const unsigned char *str, size_t length, size_t *ret_length);
|
||||
unsigned char *putil_base64_decode(const unsigned char *str, size_t length, size_t *ret_length);
|
||||
int putil_is_valid_utf8(const char *str);
|
||||
uint64_t putil_ato64(const char *str);
|
||||
uint32_t putil_ato32(const char *str);
|
||||
|
||||
static inline size_t psync_strlcpy(char *dst, const char *src, size_t size) {
|
||||
static inline size_t putil_strlcpy(char *dst, const char *src, size_t size) {
|
||||
size_t len;
|
||||
len = strlen(src);
|
||||
if (likely(len < size)) {
|
||||
|
|
|
|||
|
|
@ -486,7 +486,7 @@ static void status_change(pstatus_t *status) {
|
|||
lib_setup_cripto();
|
||||
}
|
||||
}
|
||||
psync_fs_start();
|
||||
pfs_start();
|
||||
}
|
||||
if (clib::pclsync_lib::get_lib().status_callback_) {
|
||||
clib::pclsync_lib::get_lib().status_callback_(
|
||||
|
|
|
|||
Loading…
Reference in New Issue