mirror of
https://github.com/WerWolv/ImHex.git
synced 2026-04-02 05:27:41 -05:00
fix: Store install issues when paths are symlinked
This commit is contained in:
@@ -37,7 +37,7 @@ namespace hex::plugin::builtin {
|
||||
this->getWindowOpenState() = true;
|
||||
});
|
||||
|
||||
m_httpRequest.setTimeout(30'0000);
|
||||
m_httpRequest.setTimeout(30'000);
|
||||
|
||||
addCategory("hex.builtin.view.store.tab.patterns", "patterns", &paths::Patterns);
|
||||
addCategory("hex.builtin.view.store.tab.includes", "includes", &paths::PatternsInclude);
|
||||
@@ -70,7 +70,7 @@ namespace hex::plugin::builtin {
|
||||
void updateEntryMetadata(StoreEntry &storeEntry, const StoreCategory &category) {
|
||||
// Check if file is installed already or has an update available
|
||||
for (const auto &folder : category.path->write()) {
|
||||
auto path = folder / std::fs::path(storeEntry.fileName);
|
||||
const auto path = folder / std::fs::path(storeEntry.fileName);
|
||||
|
||||
if (wolv::io::fs::exists(path)) {
|
||||
storeEntry.installed = true;
|
||||
@@ -239,10 +239,10 @@ namespace hex::plugin::builtin {
|
||||
}
|
||||
|
||||
void ViewStore::parseResponse() {
|
||||
auto response = m_apiRequest.get();
|
||||
const auto response = m_apiRequest.get();
|
||||
m_requestStatus = response.isSuccess() ? RequestStatus::Succeeded : RequestStatus::Failed;
|
||||
if (m_requestStatus == RequestStatus::Succeeded) {
|
||||
auto json = nlohmann::json::parse(response.getData());
|
||||
const auto json = nlohmann::json::parse(response.getData());
|
||||
|
||||
auto parseStoreEntries = [](auto storeJson, StoreCategory &category) {
|
||||
// Check if the response handles the type of files
|
||||
@@ -297,11 +297,10 @@ namespace hex::plugin::builtin {
|
||||
|
||||
// Verify that we write the file to the right folder
|
||||
// this is to prevent the filename from having elements like ../
|
||||
auto fullPath = std::fs::weakly_canonical(folderPath / std::fs::path(fileName));
|
||||
auto [folderIter, pathIter] = std::mismatch(folderPath.begin(), folderPath.end(), fullPath.begin());
|
||||
const auto fullPath = std::fs::absolute(folderPath / std::fs::path(fileName));
|
||||
const auto [folderIter, pathIter] = std::mismatch(folderPath.begin(), folderPath.end(), fullPath.begin());
|
||||
if (folderIter != folderPath.end()) {
|
||||
log::warn("The destination file name '{}' is invalid", fileName);
|
||||
return false;
|
||||
continue;
|
||||
}
|
||||
|
||||
downloading = true;
|
||||
|
||||
Reference in New Issue
Block a user