Skip to content

Commit 559b58c

Browse files
committed
Lookup Deluge mapped files by key, not index
jsoncons has issues with dicts with non-string keys, leading to a lookup by index into key/value pair array, not by key. Since keys are silently converted into strings when dict is loaded from bencoded data, do the same when looking up to explicitly lookup using a string key.
1 parent eb5b0ba commit 559b58c

File tree

1 file changed

+2
-6
lines changed

1 file changed

+2
-6
lines changed

Store/DelugeStateStore.cpp

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -131,19 +131,15 @@ fs::path GetChangedFilePath(ojson const& mappedFiles, std::size_t index)
131131

132132
if (!mappedFiles.is_null())
133133
{
134-
if (index < mappedFiles.size())
134+
if (const auto fileIt = mappedFiles.find(std::to_string(index)); fileIt != mappedFiles.object_range().end())
135135
{
136-
fs::path const path = Util::GetPath(mappedFiles[index].as<std::string>());
136+
fs::path const path = Util::GetPath(fileIt->value().as<std::string>());
137137
fs::path::iterator pathIt = path.begin();
138138
while (++pathIt != path.end())
139139
{
140140
result /= *pathIt;
141141
}
142142
}
143-
else
144-
{
145-
Logger(Logger::Warning) << "Mapping information missing for file #" << index;
146-
}
147143
}
148144

149145
return result;

0 commit comments

Comments
 (0)