Skip to content

Commit

Permalink
fix (ho voglia di pasta con i tonghi)
Browse files Browse the repository at this point in the history
  • Loading branch information
fefe202 committed Dec 16, 2024
1 parent 3d68f7b commit 1569033
Showing 1 changed file with 17 additions and 1 deletion.
18 changes: 17 additions & 1 deletion Backend/src/main/java/unical/demacs/rdm/utils/Scheduler.java
Original file line number Diff line number Diff line change
Expand Up @@ -460,4 +460,20 @@ private void saveSchedulesToFile(List<Schedule> schedules, String type) {
})
.collect(Collectors.toList());

String fileName = "./data/job-scheduled-by-" + type + ".json"; File dataDir = new File("./data"); if (!dataDir.exists() && !dataDir.mkdirs()) { log.error("Failed to create directory: {}", dataDir.getAbsolutePath()); throw new RuntimeException("Unable to create data directory"); } try { objectMapper.writerWithDefaultPrettyPrinter().writeValue(new File(fileName), scheduleDTOs); log.info("Successfully saved {} schedules to {}", schedules.size(), fileName); } catch (IOException e) { log.error("Failed to write schedule to file: {}", fileName, e); throw new RuntimeException("Failed to save schedule to file", e); } }}
String fileName = "./data/job-scheduled-by-" + type + ".json";
File dataDir = new File("./data");

if (!dataDir.exists() && !dataDir.mkdirs()) {
log.error("Failed to create directory: {}", dataDir.getAbsolutePath());
throw new RuntimeException("Unable to create data directory");
}

try {
objectMapper.writerWithDefaultPrettyPrinter().writeValue(new File(fileName), scheduleDTOs);
log.info("Successfully saved {} schedules to {}", schedules.size(), fileName);
} catch (IOException e) {
log.error("Failed to write schedule to file: {}", fileName, e);
throw new RuntimeException("Failed to save schedule to file", e);
}
}
}

0 comments on commit 1569033

Please sign in to comment.