Move data directory when station is renamed

This commit is contained in:
Nathan McRae 2025-02-08 17:28:52 -08:00
parent 8af3162f46
commit 475808acd8

View File

@ -10,6 +10,8 @@ import com.tearsofaunicorn.wordpress.api.model.Post;
import com.tearsofaunicorn.wordpress.api.WordpressClient;
import java.io.File;
import java.io.IOException;
import java.nio.file.Files;
import java.nio.file.Path;
import java.time.format.DateTimeFormatter;
import java.time.LocalDate;
import java.time.LocalTime;
@ -417,6 +419,7 @@ public class StationSettingsController {
}
}
Path oldDirectory = settings.stationPath();
settings.setAddress(stationAddress.get());
settings.setDigitsPerGroup(digitsPerGroup.get());
settings.setExternalProgramCommand(externalProgramCommand.get());
@ -431,6 +434,14 @@ public class StationSettingsController {
settings.setScheduleStartDate(scheduleStartDatePicker.getValue());
settings.setUsername(username.get());
try {
if (!oldDirectory.toString().equals(settings.stationPath().toString())) {
Files.move(oldDirectory, settings.stationPath());
}
} catch (IOException ex) {
logger.log(Level.SEVERE, "Failed to move directory", ex);
}
try {
DateTimeFormatter formatter = DateTimeFormatter.ofPattern("HH:mm:ss");
LocalTime startTime = LocalTime.parse(scheduleStartTimeField.getText(), formatter);