MCPcopy Create free account
hub / github.com/apache/httpd / dav_fs_move_resource

Function dav_fs_move_resource

modules/dav/fs/repos.c:1342–1433  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

1340}
1341
1342static dav_error * dav_fs_move_resource(
1343 dav_resource *src,
1344 dav_resource *dst,
1345 dav_response **response)
1346{
1347 dav_resource_private *srcinfo = src->info;
1348 dav_resource_private *dstinfo = dst->info;
1349 dav_error *err;
1350 apr_status_t rv;
1351
1352#if DAV_DEBUG
1353 if (src->hooks != dst->hooks) {
1354 /*
1355 ** ### strictly speaking, this is a design error; we should not
1356 ** ### have reached this point.
1357 */
1358 return dav_new_error(src->info->pool, HTTP_INTERNAL_SERVER_ERROR, 0, 0,
1359 "DESIGN ERROR: a mix of repositories "
1360 "was passed to move_resource.");
1361 }
1362#endif
1363
1364
1365 /* try rename first */
1366 rv = apr_file_rename(srcinfo->pathname, dstinfo->pathname, srcinfo->pool);
1367
1368 /* if we can't simply rename, then do it the hard way... */
1369 if (APR_STATUS_IS_EXDEV(rv)) {
1370 if ((err = dav_fs_copymove_resource(1, src, dst, DAV_INFINITY,
1371 response)) == NULL) {
1372 /* update resource states */
1373 dst->exists = 1;
1374 dst->collection = src->collection;
1375 src->exists = 0;
1376 src->collection = 0;
1377 }
1378
1379 return err;
1380 }
1381
1382 /* no multistatus response */
1383 *response = NULL;
1384
1385 if (rv != APR_SUCCESS) {
1386 /* ### should have a better error than this. */
1387 return dav_new_error(srcinfo->pool, HTTP_INTERNAL_SERVER_ERROR, 0, rv,
1388 "Could not rename resource.");
1389 }
1390
1391 /* Rename did work. Update resource states and move properties as well */
1392 dst->exists = 1;
1393 dst->collection = src->collection;
1394 src->exists = 0;
1395 src->collection = 0;
1396
1397 if ((err = dav_fs_copymoveset(1, src->info->pool,
1398 src, dst, NULL)) == NULL) {
1399 /* no error. we're done. go ahead and return now. */

Callers

nothing calls this directly

Calls 4

dav_new_errorFunction · 0.85
dav_fs_copymove_resourceFunction · 0.85
dav_fs_copymovesetFunction · 0.85
dav_push_errorFunction · 0.85

Tested by

no test coverage detected