Skip to content

Commit 1d33fca

Browse files
committed
Fix ne_move() to submit lock tokens for the parent collection of the
source resource if it is locked with depth 0. * src/ne_basic.c (copy_or_move): Call ne_lock_using_parent() for the source resource for the MOVE case. * test/lock.c (submit_test2): Renamed from submit_test, add MOVE handling. (submit_test): Add function, wrapper for ^. (if_movefrom): New test.
1 parent 645d185 commit 1d33fca

File tree

2 files changed

+36
-5
lines changed

2 files changed

+36
-5
lines changed

src/ne_basic.c

+5-1
Original file line numberDiff line numberDiff line change
@@ -443,7 +443,11 @@ static int copy_or_move(ne_session *sess, int is_move, int overwrite,
443443

444444
#ifdef NE_HAVE_DAV
445445
if (is_move) {
446-
ne_lock_using_resource(req, src, NE_DEPTH_INFINITE);
446+
/* Moving the resource requires any locks for the source
447+
* resource (which may be a collection), and modifies the
448+
* parent of the source. */
449+
ne_lock_using_resource(req, src, NE_DEPTH_INFINITE);
450+
ne_lock_using_parent(req, src);
447451
}
448452
ne_lock_using_resource(req, dest, NE_DEPTH_INFINITE);
449453
/* And we need to be able to add members to the destination's parent */

test/lock.c

+31-4
Original file line numberDiff line numberDiff line change
@@ -369,13 +369,15 @@ static int do_request(ne_session *sess, const char *path, int depth,
369369
#define LOCK_MODPARENT (0x01)
370370
/* Enable SharePoint hacks. */
371371
#define LOCK_SHAREPOINT (0x02)
372+
/* Use a MOVE request. */
373+
#define LOCK_MOVE (0x04)
372374

373375
/* Tests If: header submission, for a lock of depth 'lockdepth' at
374376
* 'lockpath', with a request to 'reqpath' which Depth header of
375377
* 'reqdepth'. 'flags' is bitwise-or of LOCK_* flags above. */
376-
static int submit_test(const char *lockpath, int lockdepth,
377-
const char *reqpath, int reqdepth,
378-
unsigned int flags)
378+
static int submit_test2(const char *lockpath, int lockdepth,
379+
const char *path1, const char *path2,
380+
int reqdepth, unsigned int flags)
379381
{
380382
ne_lock_store *store = ne_lockstore_create();
381383
ne_session *sess;
@@ -403,7 +405,13 @@ static int submit_test(const char *lockpath, int lockdepth,
403405
ne_lockstore_register(store, sess);
404406
ne_lockstore_add(store, lk);
405407

406-
ret = do_request(sess, reqpath, reqdepth, flags & LOCK_MODPARENT);
408+
if (flags & LOCK_MOVE) {
409+
ret = ne_move(sess, 0, path1, path2);
410+
if (ret)
411+
t_context("MOVE failed: %s", ne_get_error(sess));
412+
}
413+
else
414+
ret = do_request(sess, path1, reqdepth, flags & LOCK_MODPARENT);
407415
CALL(await_server());
408416

409417
ne_lockstore_destroy(store);
@@ -412,6 +420,19 @@ static int submit_test(const char *lockpath, int lockdepth,
412420
return ret;
413421
}
414422

423+
/* Tests If: header submission, for a lock of depth 'lockdepth' at
424+
* 'lockpath', with a request to 'reqpath' which Depth header of
425+
* 'reqdepth'. 'flags' is bitwise-or of LOCK_* flags above. */
426+
static int submit_test(const char *lockpath, int lockdepth,
427+
const char *reqpath, int reqdepth,
428+
unsigned int flags)
429+
{
430+
return submit_test2(lockpath, lockdepth,
431+
reqpath, NULL, reqdepth,
432+
flags);
433+
}
434+
435+
415436
static int if_simple(void)
416437
{
417438
return submit_test("/foo", 0, "/foo", 0, 0);
@@ -448,6 +469,11 @@ static int if_sharepoint(void)
448469
LOCK_SHAREPOINT);
449470
}
450471

472+
static int if_movefrom(void)
473+
{
474+
return submit_test2("/from", 0, "/from/here.txt", "/to", 0, LOCK_MOVE);
475+
}
476+
451477
static int serve_discovery(ne_socket *sock, void *userdata)
452478
{
453479
char buf[BUFSIZ], *resp = userdata;
@@ -703,6 +729,7 @@ ne_test tests[] = {
703729
T(if_child),
704730
T(if_covered_child),
705731
T(if_sharepoint),
732+
T(if_movefrom),
706733
T(lock_timeout),
707734
T(lock_long_timeout),
708735
T(lock_shared),

0 commit comments

Comments
 (0)