You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
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); }
The text was updated successfully, but these errors were encountered:
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); }
The text was updated successfully, but these errors were encountered: