src/server/plugins/postgresql/webdav.c

branch
webdav
changeset 313
3ad0b65ec838
parent 312
f7544e220a0f
child 314
6b1a6066ee43
equal deleted inserted replaced
312:f7544e220a0f 313:3ad0b65ec838
352 PgPropfind *pg = rq->userdata; 352 PgPropfind *pg = rq->userdata;
353 pool_handle_t *pool = rq->sn->pool; 353 pool_handle_t *pool = rq->sn->pool;
354 PGresult *result = pg->result; 354 PGresult *result = pg->result;
355 WebdavVFSProperties vfsprops = pg->vfsproperties; 355 WebdavVFSProperties vfsprops = pg->vfsproperties;
356 356
357 WSBool vfsprops_set = 0; 357 WSBool vfsprops_set = 0; // are live properties added to the response?
358 int64_t current_resource_id = pg->resource_id; 358 int64_t current_resource_id = pg->resource_id;
359 for(int r=0;r<pg->nrows;r++) { 359 for(int r=0;r<pg->nrows;r++) {
360 // columns: 360 // columns:
361 // 0: path 361 // 0: path
362 // 1: resource_id 362 // 1: resource_id
378 if(!util_strtoint(res_id, &resource_id)) { 378 if(!util_strtoint(res_id, &resource_id)) {
379 log_ereport(LOG_FAILURE, "pg_dav_propfind_do: cannot convert resource_id '%s' to int", res_id); 379 log_ereport(LOG_FAILURE, "pg_dav_propfind_do: cannot convert resource_id '%s' to int", res_id);
380 return 1; 380 return 1;
381 } 381 }
382 382
383 //char *nodename = PQgetvalue(result, r, 3);
384 if(resource_id != current_resource_id) { 383 if(resource_id != current_resource_id) {
385 // create a href string for the new resource 384 // create a href string for the new resource
386 // if the resource is a collection, it should have a trailing '/' 385 // if the resource is a collection, it should have a trailing '/'
387 size_t pathlen = strlen(path); 386 size_t pathlen = strlen(path);
388 if(pathlen == 0) { 387 if(pathlen == 0) {
400 resource = response->addresource(response, newres_href); 399 resource = response->addresource(response, newres_href);
401 vfsprops_set = FALSE; 400 vfsprops_set = FALSE;
402 current_resource_id = resource_id; 401 current_resource_id = resource_id;
403 } 402 }
404 403
405 // standard webdav properties 404 // standard webdav live properties
406 if(!vfsprops_set) { 405 if(!vfsprops_set) {
407 if(vfsprops.getresourcetype) { 406 if(vfsprops.getresourcetype) {
408 if(iscollection) { 407 if(iscollection) {
409 resource->addproperty(resource, webdav_resourcetype_collection(), 200); 408 resource->addproperty(resource, webdav_resourcetype_collection(), 200);
410 } else { 409 } else {
431 } 430 }
432 if(vfsprops.getetag) { 431 if(vfsprops.getetag) {
433 432
434 } 433 }
435 434
436
437 vfsprops_set = TRUE; 435 vfsprops_set = TRUE;
438 } 436 }
439 437
440 // dead properties 438 // dead properties
441 if(!PQgetisnull(result, r, 9)) { 439 if(!PQgetisnull(result, r, 9)) {
457 property->value.text.str = pool_strdup(pool, pvalue); 455 property->value.text.str = pool_strdup(pool, pvalue);
458 property->value.text.length = strlen(pvalue); 456 property->value.text.length = strlen(pvalue);
459 457
460 resource->addproperty(resource, property, 200); 458 resource->addproperty(resource, property, 200);
461 } 459 }
460 }
462 461
463
464 }
465
466 return 0; 462 return 0;
467 } 463 }
468 464
469 int pg_dav_propfind_finish(WebdavPropfindRequest *rq) { 465 int pg_dav_propfind_finish(WebdavPropfindRequest *rq) {
470 PgPropfind *pg = rq->userdata; 466 PgPropfind *pg = rq->userdata;

mercurial