Skip to content

Commit

Permalink
Fix UNLOCK
Browse files Browse the repository at this point in the history
  • Loading branch information
lyk0rian committed Sep 6, 2012
1 parent 2004d64 commit 309f9bb
Showing 1 changed file with 10 additions and 2 deletions.
12 changes: 10 additions & 2 deletions src/yaws_davlock.erl
Expand Up @@ -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),
Expand Down Expand Up @@ -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]) ->
Expand Down

0 comments on commit 309f9bb

Please sign in to comment.