Merge pull request #9780 from id/fix-ensure-no-colon-in-filenames

fix: ensure no colon in filenames
This commit is contained in:
Ivan Dyachkov 2023-01-18 09:36:16 +01:00 committed by GitHub
commit 430b0a03d4
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
7 changed files with 24 additions and 11 deletions

View File

@ -126,7 +126,7 @@ jobs:
- name: check logs
run: |
if cat jmeter_logs/${{ matrix.scripts_type }}.jtl | grep -e '<failure>true</failure>' > /dev/null 2>&1; then
echo "check logs filed"
echo "check logs failed"
exit 1
fi
- uses: actions/upload-artifact@v3
@ -235,7 +235,7 @@ jobs:
- name: check logs
run: |
if cat jmeter_logs/${{ matrix.scripts_type }}_${{ matrix.pgsql_tag }}.jtl | grep -e '<failure>true</failure>' > /dev/null 2>&1; then
echo "check logs filed"
echo "check logs failed"
exit 1
fi
- uses: actions/upload-artifact@v3
@ -341,7 +341,7 @@ jobs:
- name: check logs
run: |
if cat jmeter_logs/${{ matrix.scripts_type }}_${{ matrix.mysql_tag }}.jtl | grep -e '<failure>true</failure>' > /dev/null 2>&1; then
echo "check logs filed"
echo "check logs failed"
exit 1
fi
- uses: actions/upload-artifact@v3
@ -439,7 +439,7 @@ jobs:
- name: check logs
run: |
if cat jmeter_logs/${{ matrix.scripts_type }}.jtl | grep -e '<failure>true</failure>' > /dev/null 2>&1; then
echo "check logs filed"
echo "check logs failed"
exit 1
fi
- uses: actions/upload-artifact@v3
@ -531,7 +531,7 @@ jobs:
- name: check logs
run: |
if cat jmeter_logs/${{ matrix.scripts_type }}_${{ matrix.mysql_tag }}.jtl | grep -e '<failure>true</failure>' > /dev/null 2>&1; then
echo "check logs filed"
echo "check logs failed"
exit 1
fi
- uses: actions/upload-artifact@v3

View File

@ -327,9 +327,9 @@ atom(Bin) -> binary_to_existing_atom(Bin, utf8).
certs_dir(ChainName, ConfigOrID) ->
DirName = dir(ChainName, ConfigOrID),
SubDir = iolist_to_binary(filename:join(["authn", DirName])),
binary:replace(SubDir, <<":">>, <<"-">>, [global]).
emqx_misc:safe_filename(SubDir).
dir(ChainName, ID) when is_binary(ID) ->
binary:replace(iolist_to_binary([to_bin(ChainName), "-", ID]), <<":">>, <<"-">>);
emqx_misc:safe_filename(iolist_to_binary([to_bin(ChainName), "-", ID]));
dir(ChainName, Config) when is_map(Config) ->
dir(ChainName, authenticator_id(Config)).

View File

@ -55,7 +55,8 @@
readable_error_msg/1,
safe_to_existing_atom/1,
safe_to_existing_atom/2,
pub_props_to_packet/1
pub_props_to_packet/1,
safe_filename/1
]).
-export([
@ -708,3 +709,11 @@ pub_props_to_packet(Properties) ->
true
end,
maps:filtermap(F, Properties).
%% fix filename by replacing characters which could be invalid on some filesystems
%% with safe ones
-spec safe_filename(binary() | unicode:chardata()) -> binary() | [unicode:chardata()].
safe_filename(Filename) when is_binary(Filename) ->
binary:replace(Filename, <<":">>, <<"-">>, [global]);
safe_filename(Filename) when is_list(Filename) ->
string:replace(Filename, ":", "-", all).

View File

@ -216,7 +216,8 @@ recreate(Type, Name, Conf, Opts) ->
).
create_dry_run(Type, Conf0) ->
TmpPath = iolist_to_binary(["bridges-create-dry-run:", emqx_misc:gen_id(8)]),
TmpPath0 = iolist_to_binary(["bridges-create-dry-run:", emqx_misc:gen_id(8)]),
TmpPath = emqx_misc:safe_filename(TmpPath0),
Conf = emqx_map_lib:safe_atom_key_map(Conf0),
case emqx_connector_ssl:convert_certs(TmpPath, Conf) of
{error, Reason} ->

View File

@ -871,8 +871,9 @@ queue_count(Q) ->
replayq:count(Q).
disk_queue_dir(Id, Index) ->
QDir = binary_to_list(Id) ++ ":" ++ integer_to_list(Index),
filename:join([emqx:data_dir(), "resource_worker", node(), QDir]).
QDir0 = binary_to_list(Id) ++ ":" ++ integer_to_list(Index),
QDir = filename:join([emqx:data_dir(), "resource_worker", node(), QDir0]),
emqx_misc:safe_filename(QDir).
ensure_flush_timer(Data = #{tref := undefined, batch_time := T}) ->
Ref = make_ref(),

View File

@ -0,0 +1 @@
When creating disk queue directory for resource worker, substitute ':' with '-' in worker id.

View File

@ -0,0 +1 @@
在为资源缓存进程创建磁盘队列目录时在ID中用 '-' 代替 ':'。