Skip to content

Commit

Permalink
Merge pull request #332 from MarkSummerville/ShowSummaryPerformance
Browse files Browse the repository at this point in the history
Show summary performance
  • Loading branch information
SirSparkles authored Feb 14, 2018
2 parents 8b987dc + 1ba5257 commit ce87cc9
Show file tree
Hide file tree
Showing 4 changed files with 20 additions and 15 deletions.
4 changes: 2 additions & 2 deletions TVRename#/Forms/ShowSummary.cs
Original file line number Diff line number Diff line change
Expand Up @@ -200,7 +200,7 @@ private ShowSummaryData.ShowSummarySeasonData getSeasonDetails(ShowItem si, Seri
if (ei.FirstAired != null && ei.FirstAired < DateTime.Now)
epAiredCount++;

List<Alphaleonis.Win32.Filesystem.FileInfo> fl = this.mDoc.FindEpOnDisk(dfc,ei);
List<Alphaleonis.Win32.Filesystem.FileInfo> fl = this.mDoc.FindEpOnDisk(dfc,ei,false);
if (fl != null)
{
if (fl.Count != 0)
Expand Down Expand Up @@ -382,7 +382,7 @@ public override void OnMouseDown(SourceGrid.CellContext sender, MouseEventArgs e
bool first = true;
foreach (ProcessedEpisode epds in this.show.SeasonEpisodes[seas.SeasonNumber])
{
List<Alphaleonis.Win32.Filesystem.FileInfo> fl = this.gridSummary.mDoc.FindEpOnDisk(new DirFilesCache() , epds);
List<Alphaleonis.Win32.Filesystem.FileInfo> fl = this.gridSummary.mDoc.FindEpOnDisk(new DirFilesCache() , epds,false);
if ((fl != null) && (fl.Count > 0))
{
if (first)
Expand Down
12 changes: 6 additions & 6 deletions TVRename#/Settings/ShowsAndEpisodes.cs
Original file line number Diff line number Diff line change
Expand Up @@ -661,12 +661,12 @@ public Dictionary<int, List<string>> AllFolderLocations()
return this.AllFolderLocations( true);
}

public static string TTS(string s) // trim trailing slash
public Dictionary<int, List<string>> AllFolderLocationsEpCheck(bool checkExist)
{
return s.TrimEnd(System.IO.Path.DirectorySeparatorChar);
return this.AllFolderLocations(true, checkExist);
}

public Dictionary<int, List<string>> AllFolderLocations(bool manualToo)
public Dictionary<int, List<string>> AllFolderLocations(bool manualToo,bool checkExist=true)
{
Dictionary<int, List<string>> fld = new Dictionary<int, List<string>>();

Expand All @@ -677,7 +677,7 @@ public Dictionary<int, List<string>> AllFolderLocations(bool manualToo)
if (!fld.ContainsKey(kvp.Key))
fld[kvp.Key] = new List<String>();
foreach (string s in kvp.Value)
fld[kvp.Key].Add(TTS(s));
fld[kvp.Key].Add(s.TTS());
}
}

Expand All @@ -695,12 +695,12 @@ public Dictionary<int, List<string>> AllFolderLocations(bool manualToo)
continue;

string newName = this.AutoFolderNameForSeason(i);
if ((!string.IsNullOrEmpty(newName)) && (Directory.Exists(newName)))
if ((!string.IsNullOrEmpty(newName)) && (!checkExist ||(Directory.Exists(newName))))
{
if (!fld.ContainsKey(i))
fld[i] = new List<String>();
if (!fld[i].Contains(newName))
fld[i].Add(TTS(newName));
fld[i].Add(newName.TTS());
}
}
}
Expand Down
12 changes: 6 additions & 6 deletions TVRename#/TVRename/TVDoc.cs
Original file line number Diff line number Diff line change
Expand Up @@ -339,7 +339,7 @@ public bool MonitorAddSingleFolder(DirectoryInfo di2, bool andGuess, out Directo
foreach (ShowItem si in ShowItems)
{
if (si.AutoAddNewSeasons && !string.IsNullOrEmpty(si.AutoAdd_FolderBase) &&
FileHelper.FolderIsSubfolderOf(theFolder, si.AutoAdd_FolderBase))
theFolder.IsSubfolderOf(si.AutoAdd_FolderBase))
{
// we're looking at a folder that is a subfolder of an existing show
logger.Info("Rejecting {0} as it's already part of {1}.", theFolder, si.ShowName);
Expand Down Expand Up @@ -812,12 +812,12 @@ public void DoWhenToWatch(bool cachedOnly)
this.GenDict();
}

public List<FileInfo> FindEpOnDisk(DirFilesCache dfc, ProcessedEpisode pe)
public List<FileInfo> FindEpOnDisk(DirFilesCache dfc, ProcessedEpisode pe,bool checkDirectoryExist = true)
{
return this.FindEpOnDisk(dfc, pe.SI, pe);
return this.FindEpOnDisk(dfc, pe.SI, pe, checkDirectoryExist);
}

public List<FileInfo> FindEpOnDisk(DirFilesCache dfc, ShowItem si, Episode epi)
public List<FileInfo> FindEpOnDisk(DirFilesCache dfc, ShowItem si, Episode epi,bool checkDirectoryExist = true)
{
if (dfc == null)
dfc = new DirFilesCache();
Expand All @@ -828,10 +828,10 @@ public List<FileInfo> FindEpOnDisk(DirFilesCache dfc, ShowItem si, Episode epi)

int snum = epi.TheSeason.SeasonNumber;

if (!si.AllFolderLocations().ContainsKey(snum))
if (!si.AllFolderLocationsEpCheck(checkDirectoryExist).ContainsKey(snum))
return ret;

foreach (string folder in si.AllFolderLocations()[snum])
foreach (string folder in si.AllFolderLocationsEpCheck(checkDirectoryExist)[snum])
{
FileInfo[] files = dfc.Get(folder);
if (files == null)
Expand Down
7 changes: 6 additions & 1 deletion TVRename#/Utility/Helpers.cs
Original file line number Diff line number Diff line change
Expand Up @@ -202,7 +202,7 @@ public FileSystemProperties(long? totalBytes, long? freeBytes, long? availableB

public static class FileHelper
{
public static bool FolderIsSubfolderOf(string thisOne, string ofThat)
public static bool IsSubfolderOf(this string thisOne, string ofThat)
{
// need terminating slash, otherwise "c:\abc def" will match "c:\abc"
thisOne += System.IO.Path.DirectorySeparatorChar.ToString();
Expand All @@ -211,6 +211,11 @@ public static bool FolderIsSubfolderOf(string thisOne, string ofThat)
return ((thisOne.Length >= l) && (thisOne.Substring(0, l).ToLower() == ofThat.ToLower()));
}

public static string TTS(this string s) // trim trailing slash
{
return s.TrimEnd(System.IO.Path.DirectorySeparatorChar);
}

public static string GBMB(this long value, int decimalPlaces = 0)
{
const long OneKb = 1024;
Expand Down

0 comments on commit ce87cc9

Please sign in to comment.