Improve files_directory checking.

This commit is contained in:
levlam 2023-03-13 21:33:35 +03:00
parent 5b4f29e781
commit 03e7c4ce7c

View File

@ -549,10 +549,6 @@ Status TdDb::check_parameters(TdParameters &parameters) {
VLOG(td_init) << "Fix database_directory"; VLOG(td_init) << "Fix database_directory";
parameters.database_directory = "."; parameters.database_directory = ".";
} }
if (parameters.files_directory.empty()) {
VLOG(td_init) << "Fix files_directory";
parameters.files_directory = parameters.database_directory;
}
if (parameters.use_message_db && !parameters.use_chat_info_db) { if (parameters.use_message_db && !parameters.use_chat_info_db) {
VLOG(td_init) << "Fix use_chat_info_db"; VLOG(td_init) << "Fix use_chat_info_db";
parameters.use_chat_info_db = true; parameters.use_chat_info_db = true;
@ -586,13 +582,17 @@ Status TdDb::check_parameters(TdParameters &parameters) {
} }
parameters.database_directory = r_database_directory.move_as_ok(); parameters.database_directory = r_database_directory.move_as_ok();
auto r_files_directory = prepare_dir(parameters.files_directory); if (parameters.files_directory.empty()) {
if (r_files_directory.is_error()) { parameters.files_directory = parameters.database_directory;
VLOG(td_init) << "Invalid files_directory"; } else {
return Status::Error(400, PSLICE() << "Can't init files directory \"" << parameters.files_directory auto r_files_directory = prepare_dir(parameters.files_directory);
<< "\": " << r_files_directory.error()); if (r_files_directory.is_error()) {
VLOG(td_init) << "Invalid files_directory";
return Status::Error(400, PSLICE() << "Can't init files directory \"" << parameters.files_directory
<< "\": " << r_files_directory.error());
}
parameters.files_directory = r_files_directory.move_as_ok();
} }
parameters.files_directory = r_files_directory.move_as_ok();
return Status::OK(); return Status::OK();
} }