comparison installer.cpp @ 94:b2e0b5d4cc5a

Avoid creating more than one backup dir
author Chris Cannam
date Thu, 27 Feb 2020 15:04:53 +0000
parents 5ac455fba0ed
children 24d64a983fc8
comparison
equal deleted inserted replaced
93:5ac455fba0ed 94:b2e0b5d4cc5a
584 { 584 {
585 QString library = info.fileName; 585 QString library = info.fileName;
586 QString source = ":out"; 586 QString source = ":out";
587 QFile f(source + "/" + library); 587 QFile f(source + "/" + library);
588 QString destination = targetDir + "/" + library; 588 QString destination = targetDir + "/" + library;
589 QString backupDir = targetDir + "/" + 589
590 QString("saved-%1").arg(QDateTime::currentDateTime().toString 590 static QString backupDirName;
591 ("yyyyMMdd-hhmmss")); 591 if (backupDirName == "") {
592 // Static so as to be created once - don't go creating a
593 // second directory if the clock ticks over by one second
594 // between library installs
595 backupDirName =
596 QString("saved-%1").arg(QDateTime::currentDateTime().toString
597 ("yyyyMMdd-hhmmss"));
598 }
599 QString backupDir = targetDir + "/" + backupDirName;
592 600
593 if (!QDir(targetDir).exists()) { 601 if (!QDir(targetDir).exists()) {
594 QDir().mkpath(targetDir); 602 QDir().mkpath(targetDir);
595 } 603 }
596 604
967 975
968 vector<LibraryInfo> toInstall = 976 vector<LibraryInfo> toInstall =
969 getUserApprovedPluginLibraries(info, target); 977 getUserApprovedPluginLibraries(info, target);
970 978
971 if (toInstall.empty()) { // Cancelled, or nothing selected 979 if (toInstall.empty()) { // Cancelled, or nothing selected
980 SVCERR << "No libraries selected for installation, nothing to do"
981 << endl;
972 return 0; 982 return 0;
973 } 983 }
974 984
975 QProgressDialog progress(QObject::tr("Installing..."), 985 QProgressDialog progress(QObject::tr("Installing..."),
976 QObject::tr("Stop"), 0, toInstall.size() + 1); 986 QObject::tr("Stop"), 0, toInstall.size() + 1);