Move job recovery filename

This commit is contained in:
Scott Lahteine 2019-08-02 02:22:09 -05:00
parent 9ac348ef7b
commit 70ce4f5b36
2 changed files with 7 additions and 7 deletions

View file

@ -103,6 +103,8 @@ typedef struct {
class PrintJobRecovery {
public:
static constexpr char filename[5] = "/PLR";
static SdFile file;
static job_recovery_info_t info;

View file

@ -1042,10 +1042,8 @@ void CardReader::printingHasFinished() {
#if ENABLED(POWER_LOSS_RECOVERY)
constexpr char job_recovery_file_name[5] = "/PLR";
bool CardReader::jobRecoverFileExists() {
const bool exists = recovery.file.open(&root, job_recovery_file_name, O_READ);
const bool exists = recovery.file.open(&root, recovery.filename, O_READ);
if (exists) recovery.file.close();
return exists;
}
@ -1053,10 +1051,10 @@ void CardReader::printingHasFinished() {
void CardReader::openJobRecoveryFile(const bool read) {
if (!isDetected()) return;
if (recovery.file.isOpen()) return;
if (!recovery.file.open(&root, job_recovery_file_name, read ? O_READ : O_CREAT | O_WRITE | O_TRUNC | O_SYNC))
SERIAL_ECHOLNPAIR(MSG_SD_OPEN_FILE_FAIL, job_recovery_file_name, ".");
if (!recovery.file.open(&root, recovery.filename, read ? O_READ : O_CREAT | O_WRITE | O_TRUNC | O_SYNC))
SERIAL_ECHOLNPAIR(MSG_SD_OPEN_FILE_FAIL, recovery.filename, ".");
else if (!read)
SERIAL_ECHOLNPAIR(MSG_SD_WRITE_TO_FILE, job_recovery_file_name);
SERIAL_ECHOLNPAIR(MSG_SD_WRITE_TO_FILE, recovery.filename);
}
// Removing the job recovery file currently requires closing
@ -1065,7 +1063,7 @@ void CardReader::printingHasFinished() {
void CardReader::removeJobRecoveryFile() {
if (jobRecoverFileExists()) {
recovery.init();
removeFile(job_recovery_file_name);
removeFile(recovery.filename);
#if ENABLED(DEBUG_POWER_LOSS_RECOVERY)
SERIAL_ECHOPGM("Power-loss file delete");
serialprintPGM(jobRecoverFileExists() ? PSTR(" failed.\n") : PSTR("d.\n"));