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

File directory rename doesn't work when only changing character case #7

Open
davidnmbond opened this issue May 23, 2017 · 0 comments
Open

Comments

@davidnmbond
Copy link

File directory rename doesn't work when only changing character case. The issue is in FileSystemDriver.cs.

Fix is as follows:

JsonResult IDriver.Rename(string target, string name) { var fullPath = ParsePath(target); var answer = new ReplaceResponse(); answer.Removed.Add(target); RemoveThumbs(fullPath); if (fullPath.Directory != null) { var newPath = Path.Combine(fullPath.Directory.Parent.FullName, name); // Rename won't work if the case insensitive before/afters match, so must go via another name first. if (fullPath.Directory.FullName.ToLowerInvariant() == newPath.ToLowerInvariant()) { // Create a non-existing temp path string tempPath; var counter = 0; while (Directory.Exists(tempPath = newPath + counter++)) { } // Move to the temp path Directory.Move(fullPath.Directory.FullName, tempPath); // Move to the newPath Directory.Move(tempPath, newPath); } else { Directory.Move(fullPath.Directory.FullName, newPath); } answer.Added.Add(DtoBase.Create(new DirectoryInfo(newPath), fullPath.Root)); } else { var newPath = Path.Combine(fullPath.File.DirectoryName, name); File.Move(fullPath.File.FullName, newPath); answer.Added.Add(DtoBase.Create(new FileInfo(newPath), fullPath.Root)); } return Json(answer); }

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