mirror of
https://github.com/ONLYOFFICE/desktop-apps.git
synced 2026-02-10 18:05:16 +08:00
[win] updatesvc: keep license when updating via archive
This commit is contained in:
@ -760,6 +760,14 @@ void CSvcManager::startReplacingFiles(const tstring &packageType, const bool res
|
||||
if (NS_File::fileExists(tmpPath + files[i]))
|
||||
NS_File::replaceFile(tmpPath + files[i], appPath + files[i]);
|
||||
}
|
||||
|
||||
auto licenseFiles = NS_File::findFilesByPattern(tmpPath, L"LICENSE.*");
|
||||
auto eulaFiles = NS_File::findFilesByPattern(tmpPath, L"EULA.*");
|
||||
licenseFiles.insert(licenseFiles.end(), eulaFiles.begin(), eulaFiles.end());
|
||||
for (const auto &file : licenseFiles) {
|
||||
if (!NS_File::fileExists(appPath + file) && NS_File::fileExists(tmpPath + file))
|
||||
NS_File::replaceFile(tmpPath + file, appPath + file);
|
||||
}
|
||||
}
|
||||
|
||||
// To support a version without updatesvc.exe inside the working folder
|
||||
|
||||
@ -254,6 +254,30 @@ namespace NS_File
|
||||
return true;
|
||||
}
|
||||
|
||||
std::vector<wstring> findFilesByPattern(const wstring &path, const wstring &pattern)
|
||||
{
|
||||
std::vector<wstring> result;
|
||||
wstring searchPath = toNativeSeparators(path) + L"\\" + pattern;
|
||||
if (searchPath.size() > MAX_PATH - 1) {
|
||||
return result;
|
||||
}
|
||||
|
||||
WIN32_FIND_DATAW ffd;
|
||||
HANDLE hFind = FindFirstFile(searchPath.c_str(), &ffd);
|
||||
if (hFind == INVALID_HANDLE_VALUE)
|
||||
return result;
|
||||
|
||||
do {
|
||||
if (!(ffd.dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY)) {
|
||||
result.push_back(L"/" + wstring(ffd.cFileName));
|
||||
}
|
||||
|
||||
} while (FindNextFile(hFind, &ffd) != 0);
|
||||
|
||||
FindClose(hFind);
|
||||
return result;
|
||||
}
|
||||
|
||||
bool readFile(const wstring &filePath, list<wstring> &linesList)
|
||||
{
|
||||
std::wifstream file(filePath.c_str(), std::ios_base::in);
|
||||
|
||||
@ -35,6 +35,7 @@
|
||||
|
||||
#include <string>
|
||||
#include <list>
|
||||
#include <vector>
|
||||
|
||||
using std::string;
|
||||
using std::wstring;
|
||||
@ -61,6 +62,7 @@ wstring GetAppLanguage();
|
||||
namespace NS_File
|
||||
{
|
||||
bool GetFilesList(const wstring &path, list<wstring> *lst, wstring &error, bool ignore_locked = false, bool folders_only = false);
|
||||
std::vector<wstring> findFilesByPattern(const wstring &path, const wstring &pattern);
|
||||
bool readFile(const wstring &filePath, list<wstring> &linesList);
|
||||
bool readBinFile(const wstring &filePath, list<wstring> &linesList);
|
||||
bool writeToFile(const wstring &filePath, list<wstring> &linesList);
|
||||
|
||||
Reference in New Issue
Block a user