EpisodeFile cleanup and deletion fixes

Upgraded episodes will no longer be auto unmonitored
EpsiodeFiles will be removed from db if parsing rules have changed
EpisodeFiles will be removed from db if they are not in their series' folder (or subfolder)
This commit is contained in:
Mark McDowall 2013-07-22 17:50:37 -07:00
commit 4c1e6e14aa
11 changed files with 145 additions and 49 deletions

View file

@ -35,6 +35,7 @@ namespace NzbDrone.Common
bool IsFileLocked(FileInfo file);
string GetPathRoot(string path);
void SetPermissions(string filename, string account, FileSystemRights Rights, AccessControlType ControlType);
bool IsParent(string parentfolder, string subfolder);
}
public class DiskProvider : IDiskProvider
@ -383,5 +384,26 @@ namespace NzbDrone.Common
directorySecurity.AddAccessRule(accessRule);
directoryInfo.SetAccessControl(directorySecurity);
}
public bool IsParent(string parent, string subfolder)
{
parent = parent.TrimEnd(Path.DirectorySeparatorChar);
subfolder = subfolder.TrimEnd(Path.DirectorySeparatorChar);
var diParent = new DirectoryInfo(parent);
var diSubfolder = new DirectoryInfo(subfolder);
while (diSubfolder.Parent != null)
{
if (diSubfolder.Parent.FullName == diParent.FullName)
{
return true;
}
diSubfolder = diSubfolder.Parent;
}
return false;
}
}
}