Fix Power Loss Recovery file delete (#13522)

This commit is contained in:
Robby Candra 2019-03-31 01:14:58 +07:00 committed by Scott Lahteine
parent d992dfe7d5
commit a3f67acd6d
3 changed files with 4 additions and 3 deletions

View File

@ -222,6 +222,8 @@ void PrintJobRecovery::write() {
open(false); open(false);
file.seekSet(0); file.seekSet(0);
const int16_t ret = file.write(&info, sizeof(info)); const int16_t ret = file.write(&info, sizeof(info));
close();
#if ENABLED(DEBUG_POWER_LOSS_RECOVERY) #if ENABLED(DEBUG_POWER_LOSS_RECOVERY)
if (ret == -1) SERIAL_ECHOLNPGM("Power-loss file write failed."); if (ret == -1) SERIAL_ECHOLNPGM("Power-loss file write failed.");
#else #else

View File

@ -50,7 +50,7 @@ void GcodeSuite::M413() {
if (parser.seen('R') || parser.seen('L')) recovery.load(); if (parser.seen('R') || parser.seen('L')) recovery.load();
if (parser.seen('W')) recovery.save(true); if (parser.seen('W')) recovery.save(true);
if (parser.seen('P')) recovery.purge(); if (parser.seen('P')) recovery.purge();
if (parser.seen('E')) serialprintPGM(recovery.exists() ? PSTR("BIN Exists\n") : PSTR("No BIN\n")); if (parser.seen('E')) serialprintPGM(recovery.exists() ? PSTR("PLR Exists\n") : PSTR("No PLR\n"));
if (parser.seen('V')) serialprintPGM(recovery.valid() ? PSTR("Valid\n") : PSTR("Invalid\n")); if (parser.seen('V')) serialprintPGM(recovery.valid() ? PSTR("Valid\n") : PSTR("Invalid\n"));
#endif #endif
} }

View File

@ -1004,7 +1004,7 @@ void CardReader::printingHasFinished() {
#if ENABLED(POWER_LOSS_RECOVERY) #if ENABLED(POWER_LOSS_RECOVERY)
constexpr char job_recovery_file_name[4] = "BIN"; constexpr char job_recovery_file_name[4] = "PLR";
bool CardReader::jobRecoverFileExists() { bool CardReader::jobRecoverFileExists() {
const bool exists = recovery.file.open(&root, job_recovery_file_name, O_READ); const bool exists = recovery.file.open(&root, job_recovery_file_name, O_READ);
@ -1026,7 +1026,6 @@ void CardReader::printingHasFinished() {
// be zeroed and written instead of deleted. // be zeroed and written instead of deleted.
void CardReader::removeJobRecoveryFile() { void CardReader::removeJobRecoveryFile() {
if (jobRecoverFileExists()) { if (jobRecoverFileExists()) {
//closefile();
removeFile(job_recovery_file_name); removeFile(job_recovery_file_name);
#if ENABLED(DEBUG_POWER_LOSS_RECOVERY) #if ENABLED(DEBUG_POWER_LOSS_RECOVERY)
SERIAL_ECHOPGM("Power-loss file delete"); SERIAL_ECHOPGM("Power-loss file delete");