File tree Expand file tree Collapse file tree 1 file changed +28
-2
lines changed Expand file tree Collapse file tree 1 file changed +28
-2
lines changed Original file line number Diff line number Diff line change @@ -319,7 +319,7 @@ impl Create {
319
319
320
320
let content = CreateContent :: from_create ( & self , & input, env) ?;
321
321
322
- let output = content. output . resolve ( env) ?;
322
+ let mut output = content. output . resolve ( env) ?;
323
323
324
324
if content. piece_length . count ( ) == 0 {
325
325
return Err ( Error :: PieceLengthZero ) ;
@@ -336,7 +336,11 @@ impl Create {
336
336
return Err ( Error :: PieceLengthSmall ) ;
337
337
}
338
338
339
- if let OutputTarget :: Path ( path) = & output {
339
+ if let OutputTarget :: Path ( path) = & mut output {
340
+ if path. is_dir ( ) {
341
+ path. push ( format ! ( "{}.torrent" , content. name) ) ;
342
+ }
343
+
340
344
if !self . force && path. exists ( ) {
341
345
return Err ( Error :: OutputExists { path : path. clone ( ) } ) ;
342
346
}
@@ -1014,6 +1018,28 @@ mod tests {
1014
1018
env. load_metainfo ( "x.torrent" ) ;
1015
1019
}
1016
1020
1021
+ #[ test]
1022
+ fn destination_dir ( ) {
1023
+ let mut env = test_env ! {
1024
+ args: [
1025
+ "torrent" ,
1026
+ "create" ,
1027
+ "--input" ,
1028
+ "foo" ,
1029
+ "--output" ,
1030
+ "bar" ,
1031
+ "--announce" ,
1032
+ "http://bar" ,
1033
+ ] ,
1034
+ tree: {
1035
+ foo: "" ,
1036
+ bar: { } ,
1037
+ } ,
1038
+ } ;
1039
+ env. assert_ok ( ) ;
1040
+ env. load_metainfo ( "bar/foo.torrent" ) ;
1041
+ }
1042
+
1017
1043
#[ test]
1018
1044
fn created_by_default ( ) {
1019
1045
let mut env = test_env ! {
You can’t perform that action at this time.
0 commit comments