question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Data file imported twice resulting in an exception

See original GitHub issue

Hi, I’ve found this awesome tool just yesterday and was trying to rip one game but I always got this exception in the output log:

Import: System.ArgumentException: SerializedFile with name 'globalgamemanagers' already presents in the collection

So I cloned the repo to investigate what’s going on as I thought it may be a bug in UtinyRipper rather than in the game itself and found out, that the data.unity3d file is being imported twice and that results in the above exception.

I was able to find out where exactly, and why that happens:

When an instance of uTinyRipper.PCGameStructure is created, it looks for files to import:

Dictionary<string, string> files = new Dictionary<string, string>();
CollectGameFiles(dataDirectory, files);
CollectStreamingAssets(dataDirectory, files);
Files = files;

The CollectGameFiles method first looks specifically for a file with the name data.unity3d. If it finds it, the info about that file is added to the dictionary. So far, so good. But when we go to the next method - CollectAssetBundles, it looks for every file with the .unity3d extension adding the data.unity3d file to the dictionary again but now without an extension as the key. What we get is this (the blacked-out paths are exactly the same):

image

I was able to work-around this bug by modifying the condition inside the CollectAssetBundles method changing it like so:

if (file.Extension == AssetBundleExtension) // original

if (file.Name != "data.unity3d" && file.Extension == AssetBundleExtension) // with workaround

But I don’t know if this’s the best solution so I let you to decide how to fix this 😄

Another possible solution would be to call the Distinct LINQ extension method on the dictionary, probably with custom equality comparer, after it’s created to remove any possible duplicates that may be created somewhere else.

Issue Analytics

  • State:closed
  • Created 4 years ago
  • Comments:7 (4 by maintainers)

github_iconTop GitHub Comments

1reaction
mafacacommented, Jan 2, 2020

Fixed in e1dab38e73264b45bf64236bf1e05686e96459c1

0reactions
brambormancommented, Jan 15, 2020

Works perfectly. Thanks!

Read more comments on GitHub >

github_iconTop Results From Across the Web

What could cause a python module to be imported twice?
A Python module can be imported twice if the module is found twice in the path. For example, say your project is laid...
Read more >
What Happens When a Module Is Imported Twice?
A JavaScript module is evaluated just once. When imported multiple times from the same path, the same module instance is returned.
Read more >
Why can't a compiler avoid importing a header file twice by ...
So we make preprocessor directives to avoid this. But I'm not sure - why can't the compiler just... not import the same thing...
Read more >
foo.test_foo is imported twice, including once before ...
Minimal example if possible. foo.test_foo is imported twice, including once before running conftest, when using pytest --pyargs foo.test_foo .
Read more >
What Happens When you Import a Python Module?
When the package is imported, this __init__.py file is implicitly ... If we import it twice, the second import will read from the...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found