AP_Logger: ensure log directory exists before opening log

This will help with starting logs when inserting a fresh SD card which
doesn't have the ardupilot log directory on it
This commit is contained in:
Peter Barker 2020-05-11 12:18:31 +10:00 committed by Peter Barker
parent 66f8359c6b
commit 0c5d31f40f

View File

@ -82,9 +82,6 @@ void AP_Logger_File::Init()
{
AP_Logger_Backend::Init();
// create the log directory if need be
ensure_log_directory_exists();
// determine and limit file backend buffersize
uint32_t bufsize = _front._params.file_bufsize;
if (bufsize > 64) {
@ -837,6 +834,9 @@ void AP_Logger_File::start_new_log(void)
_need_rtc_update = !AP::rtc().get_utc_usec(utc_usec);
#endif
// create the log directory if need be
ensure_log_directory_exists();
EXPECT_DELAY_MS(3000);
_write_fd = AP::FS().open(_write_filename, O_WRONLY|O_CREAT|O_TRUNC);
_cached_oldest_log = 0;