From 83f80f44d2f0b146e4e23efad1a89212e8326ad1 Mon Sep 17 00:00:00 2001 From: Phil Olynyk Date: Mon, 7 Jun 2021 13:58:04 -0400 Subject: [PATCH] Backup either tgt or json Ident file --- .../SleepLib/loader_plugins/resmed_loader.cpp | 19 +++++++++++++++---- 1 file changed, 15 insertions(+), 4 deletions(-) diff --git a/oscar/SleepLib/loader_plugins/resmed_loader.cpp b/oscar/SleepLib/loader_plugins/resmed_loader.cpp index f67bcbf5..6fbf8345 100644 --- a/oscar/SleepLib/loader_plugins/resmed_loader.cpp +++ b/oscar/SleepLib/loader_plugins/resmed_loader.cpp @@ -451,16 +451,27 @@ int ResmedLoader::Open(const QString & dirpath) // Copy Identification files to backup folder - QFile backupFile(backup_path + RMS9_STR_idfile + STR_ext_TGT); + QString idfile_ext; + if (QFile(importPath+RMS9_STR_idfile+STR_ext_TGT).exists()) { + idfile_ext = STR_ext_TGT; + } + else if (QFile(importPath+RMS9_STR_idfile+STR_ext_JSON).exists()) { + idfile_ext = STR_ext_JSON; + } + else { + idfile_ext = ""; // should never happen... + } + + QFile backupFile(backup_path + RMS9_STR_idfile + idfile_ext); if (backupFile.exists()) backupFile.remove(); - if (!QFile::copy(importPath + RMS9_STR_idfile + STR_ext_TGT, backup_path + RMS9_STR_idfile + STR_ext_TGT)) - qWarning() << "Could not copy" << importPath + RMS9_STR_idfile + STR_ext_TGT << "to backup" << backupFile.fileName(); + if ( ! QFile::copy(importPath + RMS9_STR_idfile + idfile_ext, backup_path + RMS9_STR_idfile + idfile_ext)) + qWarning() << "Could not copy" << importPath + RMS9_STR_idfile + idfile_ext << "to backup" << backupFile.fileName(); backupFile.setFileName(backup_path + RMS9_STR_idfile + STR_ext_CRC); if (backupFile.exists()) backupFile.remove(); - if (!QFile::copy(importPath + RMS9_STR_idfile + STR_ext_CRC, backup_path + RMS9_STR_idfile + STR_ext_CRC)) + if ( ! QFile::copy(importPath + RMS9_STR_idfile + STR_ext_CRC, backup_path + RMS9_STR_idfile + STR_ext_CRC)) qWarning() << "Could not copy" << importPath + RMS9_STR_idfile + STR_ext_CRC << "to backup" << backup_path; }