Skip to content
Browse files

Fix UNLOCK

  • Loading branch information...
1 parent 2004d64 commit 309f9bbcdd285fafb0bcdc0a8bc0470b529a86b9 @lyk0rian lyk0rian committed Sep 6, 2012
Showing with 10 additions and 2 deletions.
  1. +10 −2 src/yaws_davlock.erl
View
12 src/yaws_davlock.erl
@@ -85,16 +85,18 @@ handle_call({lock,Path,Lock}, _From, Table) ->
handle_call({unlock,Path,Id}, _From, Table) ->
%% even if the lock is not found, its removal is succesfull
%%?elog("remove lock ~p for ~p~n",[Id,Path]),
+ StripId = strip_locktoken(Id),
Path1 = filename:split(Path),
- Table1 = do_unlock(Path1,Id,Table),
+ Table1 = do_unlock(Path1,StripId,Table),
{reply, ok, Table1};
handle_call({locked,Path}, _From, Table) ->
L = filename:split(Path),
Lock = do_locked(L,Table),
{reply, Lock, Table};
handle_call({check,Path,Id}, _From, Table) ->
L = filename:split(Path),
- Lock = do_check(L,Id,Table),
+ StripId = strip_locktoken(Id),
+ Lock = do_check(L,StripId,Table),
{reply, Lock, Table};
handle_call({discover,Path}, _From, Table) ->
L = filename:split(Path),
@@ -348,6 +350,12 @@ locktoken() ->
<<U0:32, U1:16, U2:16, U3:16, U4:48>> = UUID,
lists:flatten(io_lib:format("~8.16.0b-~4.16.0b-~4.16.0b-~4.16.0b-~12.16.0b",[U0,U1,U2,U3,U4])).
+strip_locktoken([]) ->
+ [];
+strip_locktoken(Token) ->
+ Id = lists:last(string:tokens(Token, "<:>")),
+ Id.
+
format([]) ->
[];
format(["/"|T]) ->

0 comments on commit 309f9bb

Please sign in to comment.
Something went wrong with that request. Please try again.