@@ -60,13 +60,19 @@ protected bool LoadBundle(bool readOnly = true)
6060 /// <param name="statusContext">
6161 /// The status context for interacting with <see cref="AnsiConsole.Status"/>.
6262 /// </param>
63+ /// <param name="files">
64+ /// The files to add to the bundle.
65+ /// </param>
6366 /// <param name="replace">
6467 /// A value indicating whether to replace existing entries.
6568 /// </param>
69+ /// <param name="recursive">
70+ /// A value indicating whether to add files recursively.
71+ /// </param>
6672 /// <param name="continueOnError">
6773 /// A value indicating whether to continue adding files if an error occurs.
6874 /// </param>
69- protected virtual void RunAdd ( StatusContext statusContext , bool replace , bool continueOnError )
75+ protected virtual void RunAdd ( StatusContext statusContext , string [ ] files , bool replace , bool recursive , bool continueOnError )
7076 {
7177 Logger . LogInformation ( "Running add command" ) ;
7278
@@ -85,13 +91,16 @@ protected virtual void RunAdd(StatusContext statusContext, bool replace, bool co
8591
8692 statusContext . Status ( "[yellow]Adding Files[/]" ) ;
8793
88- Logger . LogDebug ( "Discovering files in the directory: {RootPath}" , Bundle . RootPath ) ;
89- string [ ] foundFiles = Utilities . SafeEnumerateFiles ( Bundle . RootPath , "*" ) . ToArray ( ) ;
90- Logger . LogInformation ( "Discovered {FileCount} files" , foundFiles . Count ( ) ) ;
94+ if ( files . Length == 0 )
95+ {
96+ Logger . LogDebug ( "Discovering files in the directory: {RootPath}" , Bundle . RootPath ) ;
97+ files = Utilities . SafeEnumerateFiles ( Bundle . RootPath , "*" , recursive ) . ToArray ( ) ;
98+ Logger . LogInformation ( "Discovered {FileCount} files" , files . Length ) ;
99+ }
91100
92101 Logger . LogInformation ( "Starting file adder multi-thread task" ) ;
93102 bool errorOccurred = false ;
94- _ = Parallel . ForEach ( foundFiles , ( file , state ) =>
103+ _ = Parallel . ForEach ( files , ( file , state ) =>
95104 {
96105 if ( file == Bundle . BundlePath ) return ;
97106 string entryName = Manifest . GetNormalizedEntryName ( Path . GetRelativePath ( Bundle . RootPath , file ) ) ;
@@ -100,12 +109,19 @@ protected virtual void RunAdd(StatusContext statusContext, bool replace, bool co
100109
101110 try
102111 {
112+ if ( ! Utilities . IsFileWithinRoot ( file , Bundle . RootPath ) )
113+ {
114+ Logger . LogWarning ( "File {file} is outside the bundle root path" , file ) ;
115+ AnsiConsole . MarkupLine ( $ "[{ Color . Yellow } ]Ignored:[/] File { file } is outside the bundle root path") ;
116+ return ;
117+ }
118+
103119 if ( Bundle . Manifest . Entries . ContainsKey ( entryName ) )
104120 {
105121 if ( ! replace )
106122 {
107123 Logger . LogWarning ( "Entry already exists: {EntryName}" , entryName ) ;
108- AnsiConsole . MarkupLine ( $ "[{ Color . Orange1 } ]Exists:[/] { entryName } ") ;
124+ AnsiConsole . MarkupLine ( $ "[{ Color . Yellow } ]Exists:[/] { entryName } ") ;
109125 return ;
110126 }
111127
0 commit comments