Repository: CS-SI/eodag
Pull request #1220 (2024-06-18 07:32:19)

feat(plugins): flatten_top_dirs true by default
Set `flatten_top_dirs` download plugins setting to `True` by default
(flatten directory structure, removes unnecessary nested parent folders of downloaded products)

github-actions[bot]: ## Test Results
    4 files  ±  0      4 suites  ±0   4m 36s :stopwatch: - 1m 18s
  547 tests ±  0    540 :white_check_mark:  -   4   3 :zzz: ± 0   4 :x: + 4 
1 629 runs   - 559  1 564 :white_check_mark:  - 524  53 :zzz:  - 47  12 :x: +12 

For more details on these failures, see [this check](https://github.com/CS-SI/eodag/runs/26354011546).

Results for commit 59578721. ± Comparison against base commit ccf150d0.

[test-results]:data:application/gzip;base64,H4sIAOs4cWYC/03Myw7CIBCF4VdpWLsow2WKL2Mq0ITYi6GwMr67g4Xq8nyT+V9sCrPf2bWTl47tOaRzuBzHFLaVJqAmoFMqRyWxrduerf1S/6NHeBKJE6YxzLV5gI9xiyTlJ+a1NLkGU1drcqXlSUdTiQa1yaHBf9NuyxISDaaMwgGBowHvhDUSpNOIg3DGwV2ZoXfcy8my9wdxZquqCQEAAA==

github-actions[bot]: ![badge](https://raw.githubusercontent.com/CS-SI/eodag/_xml_coverage_reports/data/flatten_top_dirs_default/./badge.svg)


## Code Coverage (Ubuntu)

<details>


```
Filename                                     Stmts    Miss  Cover    Missing
-----------------------------------------  -------  ------  -------  ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
__init__.py                                     10       0  100.00%
cli.py                                         302      51  83.11%   60, 644-690, 792-843, 847
config.py                                      350      27  92.29%   81-83, 92, 100, 104-106, 183, 195, 459-461, 525-528, 575-576, 585-586, 665, 734-739, 741
crunch.py                                        5       5  0.00%    20-24
api/__init__.py                                  0       0  100.00%
api/core.py                                    762      84  88.98%   89-98, 372, 597, 641-644, 682, 719, 792, 796-801, 827, 923, 1000, 1113, 1203-1215, 1255, 1257, 1261, 1284, 1288-1299, 1312-1318, 1408-1411, 1440-1460, 1517, 1534-1537, 1549-1552, 1569-1576, 1944, 1977-1983, 2248, 2252-2255, 2269-2271, 2306
api/search_result.py                            50       6  88.00%   33-35, 70, 79, 86, 100
api/product/__init__.py                          5       0  100.00%
api/product/_assets.py                          44       6  86.36%   27-29, 79, 119, 129
api/product/_product.py                        188      27  85.64%   56-63, 67-69, 239-240, 322, 351, 412, 426-429, 442, 466-469, 512-518
api/product/metadata_mapping.py                678      83  87.76%   67-69, 131-133, 234, 266-267, 313-314, 324-336, 338, 349, 355-367, 412-413, 450, 471-474, 497, 505-506, 582-583, 607-608, 614-617, 632-633, 782, 828, 1002-1007, 1138, 1152-1172, 1192, 1197, 1307, 1329, 1343, 1356-1375, 1414, 1466, 1504-1508, 1527
api/product/drivers/__init__.py                  5       0  100.00%
api/product/drivers/base.py                      8       2  75.00%   23, 41
plugins/__init__.py                              0       0  100.00%
plugins/base.py                                 23       3  86.96%   25, 48, 55
plugins/manager.py                             133      15  88.72%   49-51, 105-110, 156, 197, 219, 223, 248, 287-288
plugins/apis/__init__.py                         0       0  100.00%
plugins/apis/base.py                             4       0  100.00%
plugins/apis/ecmwf.py                           99      15  84.85%   46-54, 150-152, 199-200, 226-228
plugins/apis/usgs.py                           175      36  79.43%   60-65, 132, 205, 239, 274-276, 281, 307-308, 313, 343-350, 361-366, 388-394, 396-402, 425
plugins/authentication/__init__.py               6       1  83.33%   31
plugins/authentication/aws_auth.py              20       2  90.00%   25-27
plugins/authentication/base.py                  19       3  84.21%   26, 34, 47
plugins/authentication/generic.py               16       3  81.25%   28, 40, 50
plugins/authentication/header.py                21       1  95.24%   28
plugins/authentication/keycloak.py              49       6  87.76%   33-35, 132, 156-161
plugins/authentication/oauth.py                 15       8  46.67%   25, 32-34, 38-41
plugins/authentication/openid_connect.py       186      19  89.78%   41-43, 121, 135-160, 168, 322-325, 349
plugins/authentication/qsauth.py                36       2  94.44%   32, 83
plugins/authentication/sas_auth.py              49       2  95.92%   32, 76
plugins/authentication/token.py                 90      17  81.11%   35-37, 79, 107, 109, 131-143, 198-201
plugins/authentication/token_exchange.py        35      19  45.71%   74-80, 92-120
plugins/crunch/__init__.py                       0       0  100.00%
plugins/crunch/base.py                          10       2  80.00%   25, 38
plugins/crunch/filter_date.py                   62      15  75.81%   30, 53-58, 72, 81, 90, 93, 105-107, 116-118, 125
plugins/crunch/filter_latest_intersect.py       50      10  80.00%   32-34, 51-52, 71, 80-83, 85, 92-95
plugins/crunch/filter_latest_tpl_name.py        33       2  93.94%   28, 86
plugins/crunch/filter_overlap.py                68      19  72.06%   28-30, 33, 72-75, 82-85, 91, 99, 110-126
plugins/crunch/filter_property.py               33       8  75.76%   29, 60-65, 68-69, 85-89
plugins/download/__init__.py                     0       0  100.00%
plugins/download/aws.py                        492     165  66.46%   77-83, 272, 285, 352-355, 369-373, 419-421, 425, 459-460, 466-470, 503, 538, 542, 549, 579-587, 591, 629-637, 644-646, 687-761, 779-840, 851-856, 872-885, 914, 929-931, 934, 944-952, 960-973, 983-1002, 1009-1021, 1062, 1088, 1133-1135, 1355
plugins/download/base.py                       260      57  78.08%   58-64, 145, 180, 319-320, 340-346, 377-381, 387-388, 432, 435-449, 461, 465, 538-542, 572-573, 581-598, 605-613, 615-619, 666, 688, 710, 718
plugins/download/creodias_s3.py                 17       9  47.06%   44-58
plugins/download/http.py                       531     132  75.14%   85-91, 124, 203-213, 215-216, 251-254, 318-321, 323-324, 331-336, 354-369, 386-388, 400, 448, 455-461, 479, 493, 507, 515-517, 533-538, 549, 567, 610-613, 635, 675, 720, 734-740, 776-840, 858, 891-900, 926-927, 954-959, 965, 968, 984, 1001-1002, 1029-1030, 1037, 1099-1105, 1160-1161, 1167, 1177, 1211, 1243, 1261-1277
plugins/download/s3rest.py                     118      27  77.12%   55-58, 121, 162, 197, 227-234, 237-239, 243, 256-262, 270-271, 274-278, 301, 322-325
plugins/search/__init__.py                      26       3  88.46%   27-31
plugins/search/base.py                         133      13  90.23%   48-53, 104, 108, 121, 271, 291, 350-351, 371, 380
plugins/search/build_search_result.py          183      24  86.89%   62, 97, 141-142, 148, 159, 295-298, 327, 384-401, 463, 466, 476, 493, 521, 523
plugins/search/cop_marine.py                   179      40  77.65%   43-44, 55, 65-66, 109-111, 123-124, 164-173, 177, 182, 197, 233, 237, 252, 256, 260, 264, 268-272, 278-281, 284-297, 314, 337, 344
plugins/search/creodias_s3.py                   55       3  94.55%   56, 74, 108
plugins/search/csw.py                          108      83  23.15%   44-46, 58-59, 63-64, 72-120, 126-139, 147-179, 197-238
plugins/search/data_request_search.py          198      65  67.17%   53, 90-93, 109, 121, 125-126, 137, 142, 147, 154, 167-170, 224-225, 229, 239-245, 250, 276-279, 287-298, 315, 317, 324-325, 327-328, 346-350, 383, 390, 401, 414, 420-432, 437
plugins/search/qssearch.py                     646      69  89.32%   102, 386, 390-396, 404-405, 511-517, 567, 583, 593, 620, 622, 665-668, 743-744, 787, 806, 821, 879, 900, 903-904, 913, 924, 933, 956, 1020-1025, 1029-1030, 1063, 1137, 1186, 1260-1264, 1330-1331, 1352, 1380-1392, 1399, 1431-1433, 1443-1449, 1493, 1508, 1528, 1631-1641
plugins/search/static_stac_search.py            73      12  83.56%   37-38, 95-122, 138, 151
rest/__init__.py                                 4       2  50.00%   21-22
rest/cache.py                                   33       7  78.79%   35-37, 53-55, 59, 68
rest/config.py                                  23       0  100.00%
rest/constants.py                                7       0  100.00%
rest/core.py                                   237      30  87.34%   83-87, 279, 363, 478, 705, 712-760
rest/server.py                                 286      55  80.77%   81-82, 108, 131-133, 246-248, 304-305, 317-333, 425-430, 458, 625-632, 661, 705-706, 729, 802-804, 821-826, 855, 857, 861-862, 866-867
rest/stac.py                                   465     123  73.55%   64-66, 319, 341, 389-392, 416-442, 447-453, 476-478, 501, 536-537, 565, 578, 623-663, 691-707, 786-799, 806, 859-860, 924, 992-994, 1213, 1223-1235, 1248-1270, 1284-1329, 1483-1484
rest/types/__init__.py                           0       0  100.00%
rest/types/collections_search.py                13      13  0.00%    18-44
rest/types/eodag_search.py                     184       9  95.11%   52-55, 235-239, 292, 295, 363
rest/types/queryables.py                        58       2  96.55%   38, 172
rest/types/stac_search.py                      127      11  91.34%   50-53, 132, 178, 193-195, 203, 207
rest/utils/__init__.py                          95      13  86.32%   51, 108-109, 128-130, 182, 192-206
rest/utils/cql_evaluate.py                      48       5  89.58%   69, 76, 90, 97, 105
rest/utils/rfc3339.py                           31       3  90.32%   78, 90, 92
types/__init__.py                              110      11  90.00%   53, 70, 129-132, 199, 214-218, 245, 258
types/bbox.py                                   43      19  55.81%   46-61, 72-74, 85-87, 99-101, 113-115, 123
types/download_args.py                           9       0  100.00%
types/queryables.py                             81       0  100.00%
types/search_args.py                            70      18  74.29%   60-64, 71-88, 104
types/whoosh.py                                 15       0  100.00%
utils/__init__.py                              501      39  92.22%   84, 89, 110-112, 193-194, 203-230, 233, 247, 329-333, 409-413, 434-436, 518, 533, 571-572, 968-971, 979-980, 1021-1022, 1204
utils/constraints.py                           119      37  68.91%   94-103, 144, 149, 153, 164, 190-192, 202, 216-232, 241-252
utils/exceptions.py                             37       2  94.59%   23, 93
utils/import_system.py                          30      20  33.33%   27, 67-81, 93-103
utils/logging.py                                29       1  96.55%   123
utils/notebook.py                               44      23  47.73%   25-29, 36-41, 58-62, 72-78, 83-87
utils/requests.py                               55      11  80.00%   69, 96, 98, 100, 102, 104, 123, 128-130, 138
utils/rest.py                                   27       1  96.30%   49
utils/stac_reader.py                           111      45  59.46%   56-57, 63-85, 95-97, 101, 143, 159-162, 215-224, 234-264
TOTAL                                         9550    1701  82.19%
```

</details>


### Diff against develop

```
Filename                    Stmts    Miss  Cover
------------------------  -------  ------  -------
plugins/download/http.py        0      -1  +0.19%
TOTAL                           0      -1  +0.01%
```


Results for commit: 59578721792ed3c9424d67783d9d2b5980d1e4fc


_Minimum allowed coverage is `70%`_


:recycle: This comment has been updated with latest results


<!-- Sticky Pull Request Commentartifacts/unit-test-results-python3.12-ubuntu-latest/coverage.xml -->
github-actions[bot]: ![badge](https://raw.githubusercontent.com/CS-SI/eodag/_xml_coverage_reports_win/data/flatten_top_dirs_default/./badge.svg)


## Code Coverage (Windows)

<details>


```
Filename                                     Stmts    Miss  Cover    Missing
-----------------------------------------  -------  ------  -------  ---------
__init__.py                                     10      10  0.00%    25-40
cli.py                                         302     302  0.00%    42-847
config.py                                      350     350  0.00%    18-752
crunch.py                                        5       5  0.00%    20-24
api/__init__.py                                  0       0  100.00%
api/core.py                                    762     762  0.00%    18-2372
api/search_result.py                            50      50  0.00%    18-185
api/product/__init__.py                          5       5  0.00%    21-26
api/product/_assets.py                          44      44  0.00%    18-129
api/product/_product.py                        188     188  0.00%    18-519
api/product/metadata_mapping.py                678     678  0.00%    18-1619
api/product/drivers/__init__.py                  5       5  0.00%    19-24
api/product/drivers/base.py                      8       8  0.00%    18-44
plugins/__init__.py                              0       0  100.00%
plugins/base.py                                 23      23  0.00%    18-68
plugins/manager.py                             133     133  0.00%    18-352
plugins/apis/__init__.py                         0       0  100.00%
plugins/apis/base.py                             4       4  0.00%    18-24
plugins/apis/ecmwf.py                           99      99  0.00%    18-270
plugins/apis/usgs.py                           175     175  0.00%    18-425
plugins/authentication/__init__.py               6       6  0.00%    19-31
plugins/authentication/aws_auth.py              20      20  0.00%    18-66
plugins/authentication/base.py                  19      19  0.00%    18-57
plugins/authentication/generic.py               16      16  0.00%    18-50
plugins/authentication/header.py                21      21  0.00%    18-107
plugins/authentication/keycloak.py              49      49  0.00%    18-162
plugins/authentication/oauth.py                 15      15  0.00%    18-41
plugins/authentication/openid_connect.py       186     186  0.00%    18-533
plugins/authentication/qsauth.py                36      36  0.00%    18-104
plugins/authentication/sas_auth.py              49      49  0.00%    18-108
plugins/authentication/token.py                 90      90  0.00%    18-215
plugins/authentication/token_exchange.py        35      35  0.00%    18-120
plugins/crunch/__init__.py                       0       0  100.00%
plugins/crunch/base.py                          10      10  0.00%    18-38
plugins/crunch/filter_date.py                   62      62  0.00%    18-129
plugins/crunch/filter_latest_intersect.py       50      50  0.00%    18-114
plugins/crunch/filter_latest_tpl_name.py        33      33  0.00%    18-98
plugins/crunch/filter_overlap.py                68      68  0.00%    18-173
plugins/crunch/filter_property.py               33      33  0.00%    18-94
plugins/download/__init__.py                     0       0  100.00%
plugins/download/aws.py                        492     492  0.00%    18-1355
plugins/download/base.py                       260     260  0.00%    18-731
plugins/download/creodias_s3.py                 17      17  0.00%    19-58
plugins/download/http.py                       531     531  0.00%    18-1360
plugins/download/s3rest.py                     118     118  0.00%    18-342
plugins/search/__init__.py                      26      26  0.00%    19-54
plugins/search/base.py                         133     133  0.00%    18-390
plugins/search/build_search_result.py          183     183  0.00%    18-551
plugins/search/cop_marine.py                   179     179  0.00%    18-356
plugins/search/creodias_s3.py                   55      55  0.00%    18-137
plugins/search/csw.py                          108     108  0.00%    18-238
plugins/search/data_request_search.py          198     198  0.00%    18-439
plugins/search/qssearch.py                     646     646  0.00%    18-1661
plugins/search/static_stac_search.py            73      73  0.00%    18-216
rest/__init__.py                                 4       4  0.00%    19-22
rest/cache.py                                   33      33  0.00%    18-70
rest/config.py                                  23      23  0.00%    18-64
rest/constants.py                                7       7  0.00%    19-27
rest/core.py                                   237     237  0.00%    18-760
rest/server.py                                 286     286  0.00%    18-878
rest/stac.py                                   465     465  0.00%    18-1514
rest/types/__init__.py                           0       0  100.00%
rest/types/collections_search.py                13      13  0.00%    18-44
rest/types/eodag_search.py                     184     184  0.00%    18-378
rest/types/queryables.py                        58      58  0.00%    18-172
rest/types/stac_search.py                      127     127  0.00%    19-272
rest/utils/__init__.py                          95      95  0.00%    19-211
rest/utils/cql_evaluate.py                      48      48  0.00%    18-119
rest/utils/rfc3339.py                           31      31  0.00%    18-94
types/__init__.py                              110     110  0.00%    19-309
types/bbox.py                                   43      43  0.00%    18-123
types/download_args.py                           9       9  0.00%    18-31
types/queryables.py                             81      81  0.00%    18-124
types/search_args.py                            70      70  0.00%    18-134
types/whoosh.py                                 15      15  0.00%    18-63
utils/__init__.py                              501     501  0.00%    24-1474
utils/constraints.py                           119     119  0.00%    18-252
utils/exceptions.py                             37      37  0.00%    18-117
utils/import_system.py                          30      30  0.00%    18-103
utils/logging.py                                29      29  0.00%    18-163
utils/notebook.py                               44      44  0.00%    18-87
utils/requests.py                               55      55  0.00%    18-138
utils/rest.py                                   27      27  0.00%    20-74
utils/stac_reader.py                           111     111  0.00%    18-264
TOTAL                                         9550    9550  0.00%
```

</details>


### Diff against develop

```
Filename                                     Stmts    Miss  Cover
-----------------------------------------  -------  ------  --------
__init__.py                                      0     +10  -100.00%
cli.py                                           0    +251  -83.11%
config.py                                        0    +322  -92.00%
api/core.py                                      0    +678  -88.98%
api/search_result.py                             0     +44  -88.00%
api/product/__init__.py                          0      +5  -100.00%
api/product/_assets.py                           0     +38  -86.36%
api/product/_product.py                          0    +161  -85.64%
api/product/metadata_mapping.py                  0    +595  -87.76%
api/product/drivers/__init__.py                  0      +5  -100.00%
api/product/drivers/base.py                      0      +6  -75.00%
plugins/base.py                                  0     +19  -82.61%
plugins/manager.py                               0    +118  -88.72%
plugins/apis/base.py                             0      +4  -100.00%
plugins/apis/ecmwf.py                            0     +84  -84.85%
plugins/apis/usgs.py                             0    +139  -79.43%
plugins/authentication/__init__.py               0      +5  -83.33%
plugins/authentication/aws_auth.py               0     +18  -90.00%
plugins/authentication/base.py                   0     +16  -84.21%
plugins/authentication/generic.py                0     +13  -81.25%
plugins/authentication/header.py                 0     +20  -95.24%
plugins/authentication/keycloak.py               0     +43  -87.76%
plugins/authentication/oauth.py                  0      +7  -46.67%
plugins/authentication/openid_connect.py         0    +167  -89.78%
plugins/authentication/qsauth.py                 0     +34  -94.44%
plugins/authentication/sas_auth.py               0     +47  -95.92%
plugins/authentication/token.py                  0     +73  -81.11%
plugins/authentication/token_exchange.py         0     +16  -45.71%
plugins/crunch/base.py                           0      +8  -80.00%
plugins/crunch/filter_date.py                    0     +47  -75.81%
plugins/crunch/filter_latest_intersect.py        0     +15  -30.00%
plugins/crunch/filter_latest_tpl_name.py         0     +31  -93.94%
plugins/crunch/filter_overlap.py                 0     +49  -72.06%
plugins/crunch/filter_property.py                0     +25  -75.76%
plugins/download/aws.py                          0    +327  -66.46%
plugins/download/base.py                         0    +201  -77.31%
plugins/download/creodias_s3.py                  0      +8  -47.06%
plugins/download/http.py                         0    +398  -74.95%
plugins/download/s3rest.py                       0     +91  -77.12%
plugins/search/__init__.py                       0     +23  -88.46%
plugins/search/base.py                           0    +115  -86.47%
plugins/search/build_search_result.py            0    +152  -83.06%
plugins/search/cop_marine.py                     0    +139  -77.65%
plugins/search/creodias_s3.py                    0     +52  -94.55%
plugins/search/csw.py                            0     +25  -23.15%
plugins/search/data_request_search.py            0    +133  -67.17%
plugins/search/qssearch.py                       0    +549  -84.98%
plugins/search/static_stac_search.py             0     +61  -83.56%
rest/__init__.py                                 0      +2  -50.00%
rest/cache.py                                    0     +11  -33.33%
rest/config.py                                   0     +19  -82.61%
rest/constants.py                                0      +7  -100.00%
rest/core.py                                     0     +85  -35.86%
rest/stac.py                                     0     +71  -15.27%
rest/types/eodag_search.py                       0    +165  -89.67%
rest/types/queryables.py                         0     +44  -75.86%
rest/types/stac_search.py                        0    +105  -82.68%
rest/utils/__init__.py                           0     +64  -67.37%
rest/utils/cql_evaluate.py                       0     +43  -89.58%
rest/utils/rfc3339.py                            0     +25  -80.65%
types/__init__.py                                0     +74  -67.27%
types/bbox.py                                    0     +24  -55.81%
types/download_args.py                           0      +9  -100.00%
types/queryables.py                              0     +81  -100.00%
types/search_args.py                             0     +52  -74.29%
types/whoosh.py                                  0     +15  -100.00%
utils/__init__.py                                0    +460  -91.82%
utils/constraints.py                             0     +82  -68.91%
utils/exceptions.py                              0     +35  -94.59%
utils/import_system.py                           0     +10  -33.33%
utils/logging.py                                 0     +28  -96.55%
utils/notebook.py                                0     +21  -47.73%
utils/requests.py                                0     +44  -80.00%
utils/rest.py                                    0     +26  -96.30%
utils/stac_reader.py                             0     +66  -59.46%
TOTAL                                            0   +7055  -73.87%
```


Results for commit: 59578721792ed3c9424d67783d9d2b5980d1e4fc


_Minimum allowed coverage is `70%`_


:recycle: This comment has been updated with latest results


<!-- Sticky Pull Request Commentartifacts/unit-test-results-python3.12-windows-latest/coverage.xml -->

Patch:
diff --git a/docs/add_provider.rst b/docs/add_provider.rst
index 9714290a..df707385 100644
--- a/docs/add_provider.rst
+++ b/docs/add_provider.rst
@@ -32,7 +32,6 @@ the `STAC client page <notebooks/tutos/tuto_stac_client.ipynb#stac-api>`_, shows
       download:
          type: AwsDownload
          base_uri: https://tamn.snapplanet.io
-         flatten_top_dirs: True
       auth:
          type: AwsAuth
          credentials:
diff --git a/docs/notebooks/api_user_guide/3_configuration.ipynb b/docs/notebooks/api_user_guide/3_configuration.ipynb
index 67116834..bd33e491 100644
--- a/docs/notebooks/api_user_guide/3_configuration.ipynb
+++ b/docs/notebooks/api_user_guide/3_configuration.ipynb
@@ -95,7 +95,6 @@
     "        download:\n",
     "            type: AwsDownload\n",
     "            base_uri: https://tamn.snapplanet.io\n",
-    "            flatten_top_dirs: True\n",
     "        auth:\n",
     "            type: AwsAuth\n",
     "            credentials:\n",
diff --git a/docs/notebooks/tutos/tuto_stac_client.ipynb b/docs/notebooks/tutos/tuto_stac_client.ipynb
index 238a45f8..4f6e2c17 100644
--- a/docs/notebooks/tutos/tuto_stac_client.ipynb
+++ b/docs/notebooks/tutos/tuto_stac_client.ipynb
@@ -110,7 +110,6 @@
     "        download:\n",
     "            type: AwsDownload\n",
     "            base_uri: https://tamn.snapplanet.io\n",
-    "            flatten_top_dirs: True\n",
     "        auth:\n",
     "            type: AwsAuth\n",
     "            credentials:\n",
@@ -375,7 +374,6 @@
     "    download:\n",
     "        type: HTTPDownload\n",
     "        base_uri: https://fake-endpoint\n",
-    "        flatten_top_dirs: True\n",
     "        outputs_prefix: %s\n",
     "\"\"\" % os.path.abspath(workspace))\n",
     "\n",
diff --git a/eodag/plugins/download/aws.py b/eodag/plugins/download/aws.py
index b252ebb6..ce1f4def 100644
--- a/eodag/plugins/download/aws.py
+++ b/eodag/plugins/download/aws.py
@@ -299,7 +299,7 @@ class AwsDownload(Download):
 
         # product conf overrides provider conf for "flatten_top_dirs"
         flatten_top_dirs = product_conf.get(
-            "flatten_top_dirs", getattr(self.config, "flatten_top_dirs", False)
+            "flatten_top_dirs", getattr(self.config, "flatten_top_dirs", True)
         )
 
         # xtra metadata needed for SAFE product
@@ -808,7 +808,7 @@ class AwsDownload(Download):
             product.product_type, {}
         )
         flatten_top_dirs = product_conf.get(
-            "flatten_top_dirs", getattr(self.config, "flatten_top_dirs", False)
+            "flatten_top_dirs", getattr(self.config, "flatten_top_dirs", True)
         )
         common_path = ""
         if flatten_top_dirs:
diff --git a/eodag/plugins/download/http.py b/eodag/plugins/download/http.py
index 57a89aba..efb59462 100644
--- a/eodag/plugins/download/http.py
+++ b/eodag/plugins/download/http.py
@@ -1072,7 +1072,7 @@ class HTTPDownload(Download):
             product.product_type, {}
         )
         flatten_top_dirs = product_conf.get(
-            "flatten_top_dirs", getattr(self.config, "flatten_top_dirs", False)
+            "flatten_top_dirs", getattr(self.config, "flatten_top_dirs", True)
         )
         ssl_verify = getattr(self.config, "ssl_verify", True)
 
@@ -1184,7 +1184,7 @@ class HTTPDownload(Download):
             product.product_type, {}
         )
         flatten_top_dirs = product_conf.get(
-            "flatten_top_dirs", getattr(self.config, "flatten_top_dirs", False)
+            "flatten_top_dirs", getattr(self.config, "flatten_top_dirs", True)
         )
 
         # count local assets
@@ -1231,6 +1231,8 @@ class HTTPDownload(Download):
             shutil.rmtree(fs_dir_path)
             # and return assets_urls[0] path
             fs_dir_path = uri_to_path(assets_urls[0])
+            # do not flatten dir
+            flatten_top_dirs = False
         # several local assets
         elif local_assets_count == len(assets_urls) and local_assets_count > 0:
             common_path = os.path.commonpath([uri_to_path(uri) for uri in assets_urls])
@@ -1238,6 +1240,8 @@ class HTTPDownload(Download):
             shutil.rmtree(fs_dir_path)
             # and return assets_urls common path
             fs_dir_path = common_path
+            # do not flatten dir
+            flatten_top_dirs = False
         # no assets downloaded but some should have been
         elif len(os.listdir(fs_dir_path)) == 0:
             raise NotAvailableError("No assets could be downloaded")
diff --git a/eodag/resources/providers.yml b/eodag/resources/providers.yml
index 45222977..3e4ad5b0 100644
--- a/eodag/resources/providers.yml
+++ b/eodag/resources/providers.yml
@@ -1657,7 +1657,6 @@
   download: !plugin
     type: AwsDownload
     requester_pays: True
-    flatten_top_dirs: True
     ssl_verify: true
     products:
       S1_SAR_GRD:
@@ -1749,7 +1748,6 @@
   download: !plugin
     type: AwsDownload
     requester_pays: True
-    flatten_top_dirs: True
     ssl_verify: true
   auth: !plugin
     type: AwsAuth
@@ -1846,7 +1844,6 @@
   download: !plugin
     type: AwsDownload
     requester_pays: True
-    flatten_top_dirs: True
     ssl_verify: true
     products:
       S2_MSI_L1C:
@@ -4226,7 +4223,6 @@
   download: !plugin
     type: HTTPDownload
     base_uri: 'https://planetarycomputer.microsoft.com/api/stac/download'
-    flatten_top_dirs: True
     auth_error_code: 403
     ssl_verify: true
   auth: !plugin
@@ -4277,7 +4273,6 @@
   download: !plugin
     type: HTTPDownload
     base_uri: https://hydroweb.next.theia-land.fr
-    flatten_top_dirs: true
     auth_error_code: 401
     ssl_verify: true
   auth: !plugin
@@ -5919,7 +5914,6 @@
   download: !plugin
     type: HTTPDownload
     base_uri: https://gateway.prod.wekeo2.eu/hda-broker/api/v1/dataaccess
-    flatten_top_dirs: true
     auth_error_code: 401
     order_enabled: true
     order_method: 'POST'
@@ -6038,7 +6032,6 @@
   download: !plugin
     type: HTTPDownload
     base_uri: https://gateway.prod.wekeo2.eu/hda-broker/api/v1/dataaccess
-    flatten_top_dirs: true
     auth_error_code: 401
     order_enabled: true
     order_method: 'POST'
@@ -6222,7 +6215,6 @@
       productIdentifier: '$.S3Path'
   download: !plugin
     type: CreodiasS3Download
-    flatten_top_dirs: True
     base_uri: 'https://eodata.cloudferro.com'
     s3_bucket: 'eodata'
     ssl_verify: true
@@ -6544,7 +6536,6 @@
     type: HTTPDownload
     base_uri: https://polytope.lumi.apps.dte.destination-earth.eu/api/v1/
     ssl_verify: true
-    flatten_top_dirs: true
     auth_error_code: 401
     order_enabled: True
     order_method: POST
@@ -6646,7 +6637,6 @@
     timeout: 20
     ssl_verify: true
     extract: true
-    flatten_top_dirs: true
     order_enabled: True
     order_method: GET
     order_on_response:
@@ -7162,7 +7152,6 @@
     type: HTTPDownload
     base_uri: 'https://api.eumetsat.int/data/download/1.0.0'
     extract: true
-    flatten_top_dirs: True
     ignore_assets: True
     ssl_verify: true
   auth: !plugin
@@ -7301,6 +7290,5 @@
     type: AwsDownload
     base_uri: https://s3.waw3-1.cloudferro.com
     bucket_path_level: 0
-    flatten_top_dirs: True
   auth: !plugin
     type: AwsAuth


Test patch:
diff --git a/tests/integration/test_search_stac_static.py b/tests/integration/test_search_stac_static.py
index 6ac38beb..1b7409c8 100644
--- a/tests/integration/test_search_stac_static.py
+++ b/tests/integration/test_search_stac_static.py
@@ -81,7 +81,6 @@ class TestSearchStacStatic(unittest.TestCase):
                 download:
                     type: HTTPDownload
                     base_uri: https://fake-endpoint
-                    flatten_top_dirs: True
         """
         )
         self.dag.set_preferred_provider(self.static_stac_provider)
diff --git a/tests/resources/file_config_override.yml b/tests/resources/file_config_override.yml
index a7e9dd4d..7116eec8 100644
--- a/tests/resources/file_config_override.yml
+++ b/tests/resources/file_config_override.yml
@@ -36,7 +36,7 @@ my_new_provider:
     download:
         type: AwsDownload
         base_uri: https://api.my_new_provider
-        flatten_top_dirs: True
+        flatten_top_dirs: false
     auth:
         type: AwsAuth
         credentials:
diff --git a/tests/test_config.py b/tests/test_config.py
index e819986e..baed0549 100644
--- a/tests/test_config.py
+++ b/tests/test_config.py
@@ -290,7 +290,6 @@ class TestConfigFunctions(unittest.TestCase):
                 download:
                     type: AwsDownload
                     base_uri: https://api.my_new_provider
-                    flatten_top_dirs: True
                 auth:
                     type: AwsAuth
                     credentials:
@@ -354,7 +353,7 @@ class TestConfigFunctions(unittest.TestCase):
             download:
                 type: AwsDownload
                 base_uri: https://api.my_new_provider
-                flatten_top_dirs: True
+                flatten_top_dirs: false
             auth:
                 type: AwsAuth
                 credentials:
@@ -410,7 +409,7 @@ class TestConfigFunctions(unittest.TestCase):
         self.assertEqual(
             my_new_provider_conf.download.base_uri, "https://api.my_new_provider"
         )
-        self.assertTrue(my_new_provider_conf.download.flatten_top_dirs)
+        self.assertFalse(my_new_provider_conf.download.flatten_top_dirs)
         self.assertIsInstance(my_new_provider_conf.auth, config.PluginConfig)
         self.assertEqual(my_new_provider_conf.auth.type, "AwsAuth")
         self.assertEqual(
diff --git a/tests/units/test_download_plugins.py b/tests/units/test_download_plugins.py
index cafa794f..2e994f42 100644
--- a/tests/units/test_download_plugins.py
+++ b/tests/units/test_download_plugins.py
@@ -633,11 +633,7 @@ class TestDownloadPluginHttp(BaseDownloadPluginTest):
         self.assertEqual(path, os.path.join(self.output_dir, "dummy_product"))
         self.assertTrue(os.path.isdir(path))
         self.assertTrue(
-            os.path.isfile(
-                os.path.join(
-                    self.output_dir, "dummy_product", "mal_for_matted", "something"
-                )
-            )
+            os.path.isfile(os.path.join(self.output_dir, "dummy_product", "something"))
         )
 
         # Check if the GET request has been called for both size request and download request