Fixed: Only clear readonly flag when file has readonly flag

This commit is contained in:
Mark McDowall 2014-03-20 22:42:31 -07:00
parent 4752ba3341
commit b47fa831ae
1 changed files with 7 additions and 2 deletions

View File

@ -401,10 +401,15 @@ namespace NzbDrone.Common.Disk
{ {
if (File.Exists(path)) if (File.Exists(path))
{ {
var newAttributes = File.GetAttributes(path) & ~(FileAttributes.ReadOnly); var attributes = File.GetAttributes(path);
if (attributes.HasFlag(FileAttributes.ReadOnly))
{
var newAttributes = attributes & ~(FileAttributes.ReadOnly);
File.SetAttributes(path, newAttributes); File.SetAttributes(path, newAttributes);
} }
} }
}
public FileAttributes GetFileAttributes(string path) public FileAttributes GetFileAttributes(string path)
{ {