1+ import contextlib
12import os
23
34from flask_sqlalchemy import SQLAlchemy
@@ -87,7 +88,7 @@ def serve_files(storage, file_id):
8788 mimetype = file .content_type ,
8889 download_name = file .filename ,
8990 )
90- elif file .get_cdn_url () is not None :
91+ elif file .get_cdn_url () is not None : # noqa: RET505
9192 """If file has public url, redirect to this url"""
9293 return app .redirect (file .get_cdn_url ())
9394 else :
@@ -105,17 +106,18 @@ def serve_files(storage, file_id):
105106 os .makedirs ("./upload_dir" , 0o777 , exist_ok = True )
106107 driver = get_driver (Provider .LOCAL )("./upload_dir" )
107108
108- # cls = get_driver(Provider.MINIO)
109- # driver = cls("minioadmin", "minioadmin", secure=False, host="127.0.0.1", port=9000)
109+ """
110+ Or with MinIO:
110111
111- try :
112+ cls = get_driver(Provider.MINIO)
113+ driver = cls("minioadmin", "minioadmin", secure=False, host="127.0.0.1", port=9000)
114+ """
115+
116+ with contextlib .suppress (ContainerAlreadyExistsError ):
112117 driver .create_container (container_name = "images" )
113- except ContainerAlreadyExistsError :
114- pass
115- try :
118+
119+ with contextlib .suppress (ContainerAlreadyExistsError ):
116120 driver .create_container (container_name = "documents" )
117- except ContainerAlreadyExistsError :
118- pass
119121
120122 StorageManager .add_storage ("images" , driver .get_container (container_name = "images" ))
121123 StorageManager .add_storage (
0 commit comments