Commit e3dbe24f authored by Hiro's avatar Hiro 🏄
Browse files

Fix potential io errors with reading index

parent b116f96f
Loading
Loading
Loading
Loading
+8 −5
Original line number Diff line number Diff line
@@ -390,12 +390,15 @@ public class CreateIndexJson extends CollecTorMain {
            // Ensure lastModified is populated in FileNode
            if (fileNode != null && currentDirectoryPath != null) {
              if (fileNode.lastModified == null) {
                String lastModified = dateTimeFormatter.format(
                    Files.getLastModifiedTime(Paths.get(fileNode.path))
                    .toInstant());
                fileNode.lastModified = lastModified;
                Path filePath = indexedPath.resolve(fileNode.path); // Ensure full path
                if (Files.exists(filePath)) {
                  fileNode.lastModified = dateTimeFormatter.format(
                      Files.getLastModifiedTime(filePath).toInstant()
                  );
                } else {
                  logger.warn("File does not exist: {}", filePath);
                }
              }

              Path directoryPath = Paths.get(currentDirectoryPath);
              Path filePath = this.indexedPath.resolve(directoryPath)
                  .resolve(Paths.get(fileNode.path));