@@ -50,6 +50,7 @@ load(Proplist) when is_list(Proplist) ->
5050 case pget (local_path , Proplist , undefined ) of
5151 undefined -> {error , " local definition file path is not configured: local_path is not set" };
5252 Path ->
53+ <<<<<<< HEAD
5354 rabbit_log :debug (" Asked to import definitions from a local file or directory at '~s '" , [Path ]),
5455 case file :read_file_info (Path , [raw ]) of
5556 {ok , FileInfo } ->
@@ -65,6 +66,15 @@ load(Proplist) when is_list(Proplist) ->
6566 _ ->
6667 Msg = rabbit_misc :format (" local definition file '~s ' does not exist or cannot be read by the node" , [Path ]),
6768 {error , {could_not_read_defs , Msg }}
69+ =======
70+ rabbit_log :debug (" Asked to import definitions from a local file or directory at '~ts '" , [Path ]),
71+ IsDir = filelib :is_dir (Path ),
72+ case IsDir of
73+ true ->
74+ load_from_local_path (true , Path );
75+ false ->
76+ load_from_single_file (Path )
77+ >>>>>>> 975 dced74c (Closes #7685 )
6878 end
6979 end ;
7080load (Map ) when is_map (Map ) ->
@@ -112,6 +122,7 @@ load_from_local_path(true, Dir) ->
112122 rabbit_log :info (" Applying definitions from directory ~s " , [Dir ]),
113123 load_from_files (file :list_dir (Dir ), Dir );
114124load_from_local_path (false , File ) ->
125+ rabbit_log :info (" Applying definitions from regular file at ~ts " , [File ]),
115126 load_from_single_file (File ).
116127
117128% %
@@ -206,6 +217,7 @@ load_from_multiple_files([File|Rest]) ->
206217 end .
207218
208219load_from_single_file (Path ) ->
220+ <<<<<<< HEAD
209221 rabbit_log :debug (" Will try to load definitions from a local file or directory at '~s '" , [Path ]),
210222 case rabbit_misc :raw_read_file (Path ) of
211223 {ok , Body } ->
@@ -214,4 +226,29 @@ load_from_single_file(Path) ->
214226 {error , E } ->
215227 rabbit_log :error (" Could not read definitions from file at '~s ', error: ~p " , [Path , E ]),
216228 {error , {could_not_read_defs , {Path , E }}}
229+ =======
230+ rabbit_log :debug (" Will try to load definitions from a local file or directory at '~ts '" , [Path ]),
231+
232+ case file :read_file_info (Path , [raw ]) of
233+ {ok , FileInfo } ->
234+ % % same check is used by Cuttlefish validation, this is to be extra defensive
235+ IsReadable = (element (4 , FileInfo ) == read ) or (element (4 , FileInfo ) == read_write ),
236+ case IsReadable of
237+ true ->
238+ case rabbit_misc :raw_read_file (Path ) of
239+ {ok , Body } ->
240+ rabbit_log :info (" Applying definitions from file at '~ts '" , [Path ]),
241+ import_raw (Body );
242+ {error , E } ->
243+ rabbit_log :error (" Could not read definitions from file at '~ts ', error: ~tp " , [Path , E ]),
244+ {error , {could_not_read_defs , {Path , E }}}
245+ end ;
246+ false ->
247+ Msg = rabbit_misc :format (" local definition file '~ts ' does not exist or cannot be read by the node" , [Path ]),
248+ {error , Msg }
249+ end ;
250+ _ ->
251+ Msg = rabbit_misc :format (" local definition file '~ts ' does not exist or cannot be read by the node" , [Path ]),
252+ {error , {could_not_read_defs , Msg }}
253+ >>>>>>> 975 dced74c (Closes #7685 )
217254 end .
0 commit comments