File tree Expand file tree Collapse file tree 1 file changed +8
-0
lines changed Expand file tree Collapse file tree 1 file changed +8
-0
lines changed Original file line number Diff line number Diff line change @@ -62,6 +62,7 @@ impl Command for EditCommand {
6262 /// `edit` handler
6363 async fn handler ( m : & ArgMatches ) -> Result < ( ) > {
6464 use crate :: { cache:: models:: Question , Cache } ;
65+ use crate :: helper:: suffix;
6566use std:: fs:: { self , File } ;
6667use std:: io:: Write ;
6768use std:: path:: Path ;
@@ -108,6 +109,13 @@ use std::path::Path;
108109let question: Question = qr?;
109110
110111if * lang == "rust" {
112+ let flat_suffix = suffix ( & lang) . map_err ( anyhow:: Error :: msg) ?; // Since suffix returns Result<&str>
113+ let pick_replaced = conf. code . pick . replace ( "${fid}" , & problem. fid . to_string ( ) ) . replace ( "${slug}" , & problem. slug . to_string ( ) ) ;
114+ let flat_path_str = format ! ( "{}/{}.{}" , conf. storage. code( ) ?, pick_replaced, flat_suffix) ;
115+ if Path :: new ( & flat_path_str) . exists ( ) {
116+ println ! ( "Note: Existing flat file at {}. Consider migrating content to new subdir structure." , flat_path_str) ;
117+ }
118+
111119 let sanitized_slug = problem. slug . to_lowercase ( ) . replace ( |c : char | !c. is_alphanumeric ( ) , "_" ) ;
112120 let code_dir_str = format ! ( "{}/{}-{}" , conf. storage. code( ) ?, problem. fid, sanitized_slug) ;
113121 let code_dir = Path :: new ( & code_dir_str) ;
You can’t perform that action at this time.
0 commit comments