We don't need it, and it's slow.
This saves a lot of DB queries
(Also replaced a strlen>0 with a faster check)
return st;
}
-/* Get the etag. */
-char *csync_statedb_get_etag( CSYNC *ctx, uint64_t jHash ) {
- char *ret = NULL;
- csync_file_stat_t *fs = NULL;
-
- if( !ctx ) {
- return NULL;
- }
-
- if( ! csync_get_statedb_exists(ctx)) return ret;
-
- fs = csync_statedb_get_stat_by_hash(ctx, jHash );
- if( fs ) {
- if( fs->etag ) {
- ret = c_strdup(fs->etag);
- }
- csync_file_stat_free(fs);
- }
-
- return ret;
-}
-
#define BELOW_PATH_QUERY "SELECT phash, pathlen, path, inode, uid, gid, mode, modtime, type, md5, fileid, remotePerm, filesize, ignoredChildrenRemote FROM metadata WHERE pathlen>? AND path LIKE(?)"
int csync_statedb_get_below_path( CSYNC *ctx, const char *path ) {
((int64_t) fs->mtime), ((int64_t) tmp->modtime),
fs->etag, tmp->etag, (uint64_t) fs->inode, (uint64_t) tmp->inode,
(uint64_t) fs->size, (uint64_t) tmp->size, fs->remotePerm, tmp->remotePerm, tmp->has_ignored_files );
- if( !fs->etag) {
- st->instruction = CSYNC_INSTRUCTION_EVAL;
- goto out;
- }
if((ctx->current == REMOTE_REPLICA && !c_streq(fs->etag, tmp->etag ))
|| (ctx->current == LOCAL_REPLICA && (!_csync_mtime_equal(fs->mtime, tmp->modtime)
// zero size in statedb can happen during migration
flag = CSYNC_FTW_FLAG_NSTAT;
}
- if( ctx->current == LOCAL_REPLICA ) {
- char *etag = NULL;
- int len = strlen( path );
- uint64_t h = c_jhash64((uint8_t *) path, len, 0);
- etag = csync_statedb_get_etag( ctx, h );
-
- if(_last_db_return_error(ctx)) {
- ctx->status_code = CSYNC_STATUS_UNSUCCESSFUL;
- SAFE_FREE(etag);
- goto error;
- }
-
- if( etag ) {
- SAFE_FREE(fs->etag);
- fs->etag = etag;
- fs->fields |= CSYNC_VIO_FILE_STAT_FIELDS_ETAG;
-
- if( c_streq(etag, "")) {
- CSYNC_LOG(CSYNC_LOG_PRIORITY_DEBUG, "Uniq ID from Database is EMPTY: %s", path);
- } else {
- CSYNC_LOG(CSYNC_LOG_PRIORITY_DEBUG, "Uniq ID from Database: %s -> %s", path, fs->etag ? fs->etag : "<NULL>" );
- }
- }
- }
-
previous_fs = ctx->current_fs;
/* Call walker function for each file */
}
}
- if (file->file_id && strlen(file->file_id) > 0) {
+ if (file->file_id && file->file_id[0]) {
item->_fileId = file->file_id;
}
if (file->directDownloadUrl) {
item->_isDirectory = file->type == CSYNC_FTW_TYPE_DIR;
- // The etag is already set in the previous sync phases somewhere. Maybe we should remove it there
- // and do it here so we have a consistent state about which tree stores information from which source.
- item->_etag = file->etag;
+ if (file->etag && file->etag[0]) {
+ item->_etag = file->etag;
+ }
item->_size = file->size;
if (!remote) {
csync_file_stat_free(st);
}
- void testEtag() {
- char *etag = csync_statedb_get_etag((CSYNC*)(&_ctx), 7145399680328529363 );
- QCOMPARE( QString::fromUtf8(etag), QLatin1String("52847f208be09"));
- SAFE_FREE(etag);
-
- etag = csync_statedb_get_etag((CSYNC*)(&_ctx), -8148768149813301136);
- QCOMPARE( QString::fromUtf8(etag), QLatin1String("530d148493894"));
- SAFE_FREE(etag);
- }
-
void cleanupTestCase() {
SAFE_FREE(_ctx.statedb.file);
csync_statedb_close((CSYNC*)(&_ctx));