void ListUpdater::finish(DownloadOperation operation) { if (operation == DOWNLOAD_HASH) { if (compareHashes()) { // No new updates removeServerHashFile(); emit finished(NO_UPDATE); return ; } downloadList(); } else if (operation == DOWNLOAD_LIST) { removeOldFiles(); renameNewFiles(); emit finished(UPDATE); } }
void RollingFileAppender::rollOver() { Q_ASSERT_X(!m_datePatternString.isEmpty(), "DailyRollingFileAppender::rollOver()", "No active date pattern"); QString rollOverSuffix = m_rollOverSuffix; computeRollOverTime(); if (rollOverSuffix == m_rollOverSuffix) return; closeFile(); QString targetFileName = fileName() + rollOverSuffix; QFile f(targetFileName); if (f.exists() && !f.remove()) return; f.setFileName(fileName()); if (!f.rename(targetFileName)) return; openFile(); removeOldFiles(); }
void UMcf::install(const wchar_t* path) { m_bCanceled = false; FileHandle fh(m_szFile.c_str(), m_uiOffset); if (!fh.isValid()) throw gcException(ERR_INVALIDFILE, GetLastError(), gcString("Failed to open update file {0}.", m_szFile)); #ifdef WIN32 if (m_bShouldMoveOldFiles) removeOldFiles(path); #endif //sort by offset so we are not seeking all over the place std::sort(m_pFileList.begin(), m_pFileList.end(), &SortMcfFiles); m_uiTotProgress = 0; m_uiCurProgress = 0; for (size_t x=0; x<m_pFileList.size(); x++) { if (m_pFileList[x]->isCompressed()) m_uiTotProgress += m_pFileList[x]->getCSize(); else m_uiTotProgress += m_pFileList[x]->getSize(); } for(size_t x=0; x<m_pFileList.size(); x++) { if (m_bCanceled) throw gcException(ERR_USERCANCELED); if (!m_pFileList[x] || !m_pFileList[x]->isSaved()) continue; #ifdef WIN32 if (m_bShouldMoveOldFiles) moveOldFiles(path, m_pFileList[x]->getName()); #else m_pFileList[x]->remove(path); #endif uint8 res = m_pFileList[x]->readMCFAndSave(fh.hFileSrc, path?path:L".\\", m_uiOffset, delegate(this, &UMcf::onFileProgress)); if (m_bCanceled) throw gcException(ERR_USERCANCELED); if (res == MCFF_ERR_BADHASH) throw gcException(ERR_CSUM_FAILED, gcString("Check sum failed on file {0}\\{1}", m_pFileList[x]->getPath(), m_pFileList[x]->getName())); if (res == MCFF_ERR_INVALIDHANDLE) throw gcException(ERR_INVALID, gcString("Could not open file {0}\\{1} for updating. Sys Code: {2}", m_pFileList[x]->getPath(), m_pFileList[x]->getName(), GetLastError())); if ( res != 0 && res != MCF_NOTCOMPRESSED && res != MCFF_ERR_PARTREAD ) throw gcException(ERR_INVALID, gcString("Failed to update file {0}\\{1}: {2}.", m_pFileList[x]->getPath(), m_pFileList[x]->getName(), (uint32)res)); if (m_pFileList[x]->isCompressed()) m_uiCurProgress += m_pFileList[x]->getCSize(); else m_uiCurProgress += m_pFileList[x]->getSize(); } }