Skip to content

Commit

Permalink
Merge pull request #123 from lyk0rian/dav-rework
Browse files Browse the repository at this point in the history
Fixed connection of some WebDAV clients: Cyberduck, Windows Explorer
  • Loading branch information
Claes Wikstrom committed Sep 7, 2012
2 parents 61d5571 + 309f9bb commit e72a28f
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 3 deletions.
4 changes: 3 additions & 1 deletion src/yaws_dav.erl
Expand Up @@ -329,7 +329,7 @@ proppatch(A) ->
Req = binary_to_list(A#arg.clidata),
R = davresource0(A),
Update = parse_proppatch(Req),
Response = proppatch_response(Update,A,R),
Response = {'D:response', [], proppatch_response(Update,A,R)},
MultiStatus = [{'D:multistatus', [{'xmlns:D',"DAV:"}], [Response]}],
status(207,MultiStatus)
catch
Expand Down Expand Up @@ -445,6 +445,8 @@ prop_get({'DAV:',getetag},_A,R) ->
%%?elog("ETAG: ~p~n",[E]),
P = {'D:getetag', [], [E]},
{200, P};
prop_get({'DAV:',ishidden},_A,R) when R#resource.name =:= "/" ->
{200, {'D:ishidden', [], ["0"]}};
prop_get({'DAV:',ishidden},_A,R) ->
N = filename:basename(R#resource.name),
H = case hd(N) of
Expand Down
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 e72a28f

Please sign in to comment.