Navigation Menu

Skip to content

Commit

Permalink
Case sensitive fix for remane issue
Browse files Browse the repository at this point in the history
  • Loading branch information
SirSparkles committed Oct 1, 2018
1 parent 08029af commit 2ea61c8
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 2 deletions.
6 changes: 4 additions & 2 deletions TVRename/TVRename/TVDoc.cs
Expand Up @@ -1366,8 +1366,10 @@ private void RenameAndMissingCheck(ShowItem si, DirFilesCache dfc,bool fullscan)
if (newName != actualFile.Name)
{
//Check that the file does not already exist
if (newFile.Exists)
{
//if (FileHelper.FileExistsCaseSensitive(newFile.FullName))
if (FileHelper.FileExistsCaseSensitive(files,newFile))

{
Logger.Warn($"Identified that {actualFile.FullName} should be renamed to {newName}, but it already exists.");
}
else
Expand Down
14 changes: 14 additions & 0 deletions TVRename/Utility/Helper/FileHelper.cs
@@ -1,4 +1,5 @@
using System;
using System.Linq;
using System.Text.RegularExpressions;
using Alphaleonis.Win32.Filesystem;
using Microsoft.WindowsAPICodePack.Shell;
Expand Down Expand Up @@ -42,6 +43,14 @@ public static int GetFilmLength(this FileInfo movieFile)
+ int.Parse(duration.Split(':')[2]);
}

public static bool FileExistsCaseSensitive(string filename)
{
string name = Path.GetDirectoryName(filename);

return name != null
&& Array.Exists(Directory.GetFiles(name), s => s == Path.GetFullPath(filename));
}

public static bool SameDirectoryLocation(this string directoryPath1, string directoryPath2)
{
// http://stackoverflow.com/questions/1794025/how-to-check-whether-2-directoryinfo-objects-are-pointing-to-the-same-directory
Expand Down Expand Up @@ -209,5 +218,10 @@ public static bool IgnoreFile(FileInfo fi)

return false;
}

internal static bool FileExistsCaseSensitive(FileInfo[] files, FileInfo newFile)
{
return files.Any(testFile => string.Equals(testFile.Name, newFile.Name, StringComparison.CurrentCulture));
}
}
}

0 comments on commit 2ea61c8

Please sign in to comment.