Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Link to torrent: uncaught exception with files in relative data path #3

Open
bmn opened this issue Oct 21, 2022 · 1 comment
Open

Comments

@bmn
Copy link

bmn commented Oct 21, 2022

When using Link to torrent > Check Files,
and within the torrent there is 1+ file in the directory specified by "Torrent relative data path"
and the value given to "Torrent relative data path" does not end with a directory separator

...an uncaught exception occurs:

System.ArgumentOutOfRangeException: 'startIndex cannot be larger than length of string. Arg_ParamName_Name'

This doesn't affect most Bemani games (I think DDR A/20 is an exception) if the "data" directory is used, as recommended.

The cause AFAICT is that, when the first file in the torrent (within the relative path) is checked, RelativePath is given a separator if it doesn't have one, then its new length is used to try to get a substring from the file's directory path (which doesn't have a separator).

Related code:

if (relPath.StartsWith(RelativePath))
{
string relPathQ = relPath;
if (relPath != string.Empty && !string.IsNullOrEmpty(RelativePath))
{
if (!Path.EndsInDirectorySeparator(RelativePath))
{
RelativePath += Path.DirectorySeparatorChar;
}
relPathQ = relPath.Substring(RelativePath.Length);
}

Also, if I understand the code correctly:
Exception on the first file aside, relPath.StartsWith(RelativePath) would return false for any other files in the relative data path.
Again, this doesn't affect most Bemani games, but any such files would not be handled.

@bmn bmn changed the title Link to torrent: uncaught exception related to files existing in relative data path Link to torrent: uncaught exception with files in relative data path Oct 21, 2022
@bmn
Copy link
Author

bmn commented Oct 23, 2022

Done a little more testing, and Link to torrent does skip any files that are in the same directory as the relative data path.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant