@@ -26,6 +26,7 @@ int main( int argc, char** argv )
2626 std::string host;
2727 std::filesystem::path certPath, keyPath, uploads;
2828 int port;
29+ bool clearUploads;
2930 Controller::Config config;
3031
3132 po::options_description desc ( " Simple Inference Server" );
@@ -38,6 +39,7 @@ int main( int argc, char** argv )
3839 ( " cert" , po::value ( &certPath )->default_value ( {} ), " Path to SSL certificate" )
3940 ( " key" , po::value ( &keyPath )->default_value ( {} ), " Path to SSL key" )
4041 ( " uploads" , po::value ( &uploads )->default_value ( " uploads" ), " Folder to store uploaded files" )
42+ ( " clear_uploads" , po::bool_switch ( &clearUploads )->default_value ( false ), " Clear uploads folder" )
4143 ;
4244
4345 po::variables_map vm;
@@ -58,8 +60,18 @@ int main( int argc, char** argv )
5860 return -1 ;
5961 }
6062
61- // check that uploads directory is writable (or that we can create it)
6263 std::error_code ec;
64+ if ( std::filesystem::exists ( uploads, ec ) && clearUploads )
65+ {
66+ std::filesystem::remove_all ( uploads, ec );
67+ if ( ec )
68+ {
69+ spdlog::error ( " Could not remove uploads directory: {}" , ec.message () );
70+ return -1 ;
71+ }
72+ }
73+
74+ // check that uploads directory is writable (or that we can create it)
6375 if ( std::filesystem::exists ( uploads, ec ) )
6476 {
6577 const auto checkDir = uploads / " check" ;
0 commit comments