From 05c2885d18f8313ca8f2373671d38c93445f5873d0d85a04b48899d15b3477cc Mon Sep 17 00:00:00 2001 From: ADAM David Alan Martin Date: Sat, 31 Oct 2026 18:12:36 -0400 Subject: [PATCH] Fix crash/exception of file size absence. Again, due to broken symlink. --- cudir.cc | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) diff --git a/cudir.cc b/cudir.cc index 57317b4..1a74dcc 100644 --- a/cudir.cc +++ b/cudir.cc @@ -38,7 +38,19 @@ getEntries( const std::filesystem::path where ) const auto time_since_midnight= day - time; const std::chrono::hh_mm_ss time_of_day{ std::chrono::floor< std::chrono::minutes >( time_since_midnight ) }; - entries.push_back( Entry{ entry.path().filename(), drwx( entry ), entry.is_directory() ? 0 : file_size( entry.path() ), + auto get_file_size= []( auto &path ) + { + try + { + return file_size( path ); + } + catch( const std::filesystem::filesystem_error & ) + { + return 0ul; + } + }; + + entries.push_back( Entry{ entry.path().filename(), drwx( entry ), entry.is_directory() ? 0 : get_file_size( entry.path() ), static_cast< int >( ymd.year() ), static_cast< unsigned >( ymd.month() ), static_cast< unsigned >( ymd.day() ), time_of_day.hours().count(), time_of_day.minutes().count(), entry.is_directory(), is_exe( entry ) } );