]> granicus.if.org Git - ejabberd/commitdiff
Improve code for directory deletion
authorEvgeny Khramtsov <ekhramtsov@process-one.net>
Mon, 29 Apr 2019 15:50:54 +0000 (18:50 +0300)
committerEvgeny Khramtsov <ekhramtsov@process-one.net>
Mon, 29 Apr 2019 15:50:54 +0000 (18:50 +0300)
src/mod_http_upload.erl

index 1d95829611367e4246219d2e52c5dc303c30d5ab..b3600e7094f5d9fdc4683b350fb2bea8ad2ab089 100644 (file)
@@ -975,9 +975,7 @@ remove_user(User, Server) ->
     end,
     ok.
 
--spec del_tree(file:filename_all()) -> ok | {error, term()}.
-del_tree(Dir) when is_binary(Dir) ->
-    del_tree(binary_to_list(Dir));
+-spec del_tree(file:filename_all()) -> ok | {error, file:posix()}.
 del_tree(Dir) ->
     try
        {ok, Entries} = file:list_dir(Dir),
@@ -988,11 +986,9 @@ del_tree(Dir) ->
                                  false ->
                                      ok = file:delete(Path)
                              end
-                     end, [Dir ++ "/" ++ Entry || Entry <- Entries]),
+                     end, [filename:join(Dir, Entry) || Entry <- Entries]),
        ok = file:del_dir(Dir)
     catch
        _:{badmatch, {error, Error}} ->
-           {error, Error};
-       _:Error ->
            {error, Error}
     end.