5353import java .io .UncheckedIOException ;
5454import java .net .URI ;
5555import java .net .URISyntaxException ;
56+ import java .nio .file .NoSuchFileException ;
5657import java .nio .file .attribute .BasicFileAttributes ;
5758import java .nio .file .attribute .FileTime ;
5859import java .time .Clock ;
@@ -792,7 +793,10 @@ private HttpResponse listDownloadedFiles(File downloadsDirectory) {
792793 File [] files = Optional .ofNullable (downloadsDirectory .listFiles ()).orElse (new File [] {});
793794 List <String > fileNames = Arrays .stream (files ).map (File ::getName ).collect (Collectors .toList ());
794795 List <DownloadedFile > fileInfos =
795- Arrays .stream (files ).map (this ::getFileInfo ).collect (Collectors .toList ());
796+ Arrays .stream (files )
797+ .map (this ::getFileInfo )
798+ .filter (file -> file .getLastModifiedTime () > 0 )
799+ .collect (Collectors .toList ());
796800
797801 Map <String , Object > data =
798802 Map .of (
@@ -810,6 +814,8 @@ private DownloadedFile getFileInfo(File file) {
810814 attributes .creationTime ().toMillis (),
811815 attributes .lastModifiedTime ().toMillis (),
812816 attributes .size ());
817+ } catch (NoSuchFileException e ) {
818+ return new DownloadedFile (file .getName (), -1 , -1 , -1 );
813819 } catch (IOException e ) {
814820 throw new UncheckedIOException ("Failed to get file attributes: " + file .getAbsolutePath (), e );
815821 }
0 commit comments