More tidying up

This commit is contained in:
Phil Olynyk 2020-05-16 16:16:10 -04:00
parent 209998fe34
commit 16cd85ab02

View File

@ -1539,7 +1539,8 @@ void BackupSTRfiles( const QString strpath, const QString importPath, const QStr
qDebug() << "STR file list size is" << strfiles.size(); qDebug() << "STR file list size is" << strfiles.size();
#endif #endif
// Now place any of these files in the Backup folder sorted by the file date // Now copy any of these files to the Backup folder adding the file date to the file name
// and put it into the STRmap structure
for (auto & filename : strfiles) { for (auto & filename : strfiles) {
ResMedEDFInfo * stredf = new ResMedEDFInfo(); ResMedEDFInfo * stredf = new ResMedEDFInfo();
if ( ! stredf->Open(filename) ) { if ( ! stredf->Open(filename) ) {
@ -1567,8 +1568,8 @@ void BackupSTRfiles( const QString strpath, const QString importPath, const QStr
continue; continue;
} }
} }
QString newname = "STR-"+date.toString("yyyyMMdd")+"."+STR_ext_EDF;
QString newname = "STR-"+date.toString("yyyyMMdd")+"."+STR_ext_EDF;
QString backupfile = strBackupPath+"/"+newname; QString backupfile = strBackupPath+"/"+newname;
QString gzfile = backupfile + STR_ext_gz; QString gzfile = backupfile + STR_ext_gz;
@ -1577,6 +1578,8 @@ void BackupSTRfiles( const QString strpath, const QString importPath, const QStr
bool compress_backups = p_profile->session->compressBackupData(); bool compress_backups = p_profile->session->compressBackupData();
backupfile = compress_backups ? gzfile : nongzfile; backupfile = compress_backups ? gzfile : nongzfile;
STRmap[date] = STRFile(backupfile, days, stredf);
if ( ! QFile::exists(backupfile)) { if ( ! QFile::exists(backupfile)) {
#ifdef STR_DEBUG #ifdef STR_DEBUG
qDebug() << "Copying" << filename << "to" << backupfile; qDebug() << "Copying" << filename << "to" << backupfile;
@ -1595,13 +1598,12 @@ void BackupSTRfiles( const QString strpath, const QString importPath, const QStr
} }
} }
} }
// Remove any duplicate compressed/uncompressed backup file // Remove any duplicate compressed/uncompressed backup file
if (compress_backups) if (compress_backups)
QFile::exists(nongzfile) && QFile::remove(nongzfile); QFile::exists(nongzfile) && QFile::remove(nongzfile);
else else
QFile::exists(gzfile) && QFile::remove(gzfile); QFile::exists(gzfile) && QFile::remove(gzfile);
STRmap[date] = STRFile(backupfile, days, stredf);
} // end for walking the STR files list } // end for walking the STR files list
#ifdef STR_DEBUG #ifdef STR_DEBUG
qDebug() << "STRmap has" << STRmap.size() << "entries"; qDebug() << "STRmap has" << STRmap.size() << "entries";