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

Renaming error in case of file duplication #136

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

indexlang
Copy link

@@ -120,11 +120,11 @@ public FileRepository(IDbContextProvider<IFileManagementDbContext> dbContextProv
var nextNumber =
fileNames
.Select(x =>
x.Substring(part1.Length, x.LastIndexOf(part2, StringComparison.Ordinal) - part1.Length))
x.LastIndexOf(part2, StringComparison.Ordinal) > 0 ? x.Substring(part1.Length, x.LastIndexOf(part2, StringComparison.Ordinal) - part1.Length) : "")
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

How about

                    .Where(x => x.EndsWith(part2, StringComparison.Ordinal))

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It's Ok,but why add new line?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No need to select and parse unused items ("").

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If client upload a file end with ")",also need parse str,so I think both are fine,you decide.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I prefer to keep the .Select() line unchanged and add

                    .Where(x => x.EndsWith(part2, StringComparison.Ordinal))

for minimal impact.

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

Successfully merging this pull request may close these issues.

2 participants