Merge branch 'develop' of github.com:NzbDrone/NzbDrone into develop

pull/6/head
kay.one 11 years ago
commit d65163f2be

@ -4,6 +4,7 @@ using System.IO;
using System.Linq;
using System.Runtime.InteropServices;
using System.Security.AccessControl;
using System.Security.Principal;
using NLog;
using NzbDrone.Common.EnsureThat;
using NzbDrone.Common.EnvironmentInfo;
@ -38,7 +39,7 @@ namespace NzbDrone.Common
void FolderSetLastWriteTimeUtc(string path, DateTime dateTime);
bool IsFileLocked(FileInfo file);
string GetPathRoot(string path);
void SetPermissions(string filename, string account, FileSystemRights rights, AccessControlType controlType);
void SetPermissions(string filename, WellKnownSidType accountSid, FileSystemRights rights, AccessControlType controlType);
bool IsParent(string parentPath, string childPath);
FileAttributes GetFileAttributes(string path);
}
@ -243,7 +244,6 @@ namespace NzbDrone.Common
break;
}
}
}
}
@ -403,17 +403,16 @@ namespace NzbDrone.Common
return Path.GetPathRoot(path);
}
public void SetPermissions(string filename, string account, FileSystemRights rights, AccessControlType controlType)
public void SetPermissions(string filename, WellKnownSidType accountSid, FileSystemRights rights, AccessControlType controlType)
{
try
{
var sid = new SecurityIdentifier(accountSid, null);
var directoryInfo = new DirectoryInfo(filename);
var directorySecurity = directoryInfo.GetAccessControl();
var accessRule = new FileSystemAccessRule(account, rights,
var accessRule = new FileSystemAccessRule(sid, rights,
InheritanceFlags.ContainerInherit | InheritanceFlags.ObjectInherit,
PropagationFlags.None, controlType);
@ -423,7 +422,7 @@ namespace NzbDrone.Common
}
catch (Exception e)
{
Logger.WarnException(string.Format("Couldn't set permission for {0}. account:{1} rights:{2} accessControlType:{3}", filename, account, rights, controlType), e);
Logger.WarnException(string.Format("Couldn't set permission for {0}. account:{1} rights:{2} accessControlType:{3}", filename, accountSid, rights, controlType), e);
throw;
}

@ -2,6 +2,7 @@
using System.IO;
using System.Reflection;
using System.Security.AccessControl;
using System.Security.Principal;
using NLog;
namespace NzbDrone.Common.EnvironmentInfo
@ -47,7 +48,7 @@ namespace NzbDrone.Common.EnvironmentInfo
{
try
{
_diskProvider.SetPermissions(AppDataFolder, "Everyone", FileSystemRights.FullControl, AccessControlType.Allow);
_diskProvider.SetPermissions(AppDataFolder, WellKnownSidType.WorldSid, FileSystemRights.FullControl, AccessControlType.Allow);
}
catch (Exception ex)
{

@ -80,6 +80,10 @@ namespace NzbDrone.Core.Test.MediaFileTests
{
GivenEpisodeFiles();
Mocker.GetMock<IMoveEpisodeFiles>()
.Setup(s => s.MoveEpisodeFile(It.IsAny<EpisodeFile>(), It.IsAny<Series>()))
.Throws(new SameFilenameException("Same file name", "Filename"));
Subject.Execute(new RenameSeriesCommand(_series.Id));
Mocker.GetMock<IMessageAggregator>()

@ -2,6 +2,7 @@
using System.Drawing;
using System.Linq;
using System.Xml.Linq;
using NLog;
using NzbDrone.Core.Parser.Model;
namespace NzbDrone.Core.Indexers.Newznab
@ -20,7 +21,13 @@ namespace NzbDrone.Core.Indexers.Newznab
if (currentResult != null)
{
var attributes = item.Elements(NewznabNamespace + "attr");
var sizeElement = attributes.Single(e => e.Attribute("name").Value == "size");
var sizeElement = attributes.SingleOrDefault(e => e.Attribute("name").Value == "size");
if (sizeElement == null)
{
var message = String.Format("Unable to parse size from: {0} [{1}]", currentResult.Title, currentResult.Indexer);
throw new SizeParsingException(message);
}
currentResult.Size = Convert.ToInt64(sizeElement.Attribute("value").Value);
}

@ -0,0 +1,14 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
namespace NzbDrone.Core.Indexers.Newznab
{
public class SizeParsingException : Exception
{
public SizeParsingException(string message) : base(message)
{
}
}
}

@ -62,15 +62,12 @@ namespace NzbDrone.Core.MediaFiles
{
if (!_diskProvider.FileExists(episodeFile.Path))
{
_logger.Error("Episode file path does not exist, {0}", episodeFile.Path);
return null;
throw new FileNotFoundException("Episode file path does not exist", episodeFile.Path);
}
//Only rename if existing and new filenames don't match
if (DiskProvider.PathEquals(episodeFile.Path, destinationFilename))
{
_logger.Debug("Skipping file rename, source and destination are the same: {0}", episodeFile.Path);
return null;
throw new SameFilenameException("File not moved, source and destination are the same", episodeFile.Path);
}
_diskProvider.CreateFolder(new FileInfo(destinationFilename).DirectoryName);

@ -68,13 +68,6 @@ namespace NzbDrone.Core.MediaFiles.EpisodeImport
if (newDownload)
{
episodeFile = _episodeFileUpgrader.UpgradeEpisodeFile(episodeFile, localEpisode);
if (episodeFile == null)
{
_logger.Error("Failed to move [{0}], aborting processing", localEpisode);
continue;
}
_messageAggregator.PublishEvent(new EpisodeImportedEvent(episodeFile));
}

@ -1,4 +1,5 @@
using System.Collections.Generic;
using System;
using System.Collections.Generic;
using System.Linq;
using NLog;
using NzbDrone.Common.Messaging;
@ -35,18 +36,26 @@ namespace NzbDrone.Core.MediaFiles
foreach (var file in episodeFiles)
{
var episodeFile = file;
try
{
var episodeFile = file;
_logger.Trace("Renaming episode file: {0}", episodeFile);
episodeFile = _episodeFileMover.MoveEpisodeFile(episodeFile, series);
_logger.Trace("Renaming episode file: {0}", episodeFile);
episodeFile = _episodeFileMover.MoveEpisodeFile(episodeFile, series);
if (episodeFile != null)
{
_mediaFileService.Update(episodeFile);
renamed.Add(episodeFile);
}
_logger.Trace("Renamed episode file: {0}", episodeFile);
_logger.Trace("Renamed episode file: {0}", episodeFile);
}
catch (SameFilenameException ex)
{
_logger.Trace("File not renamed, source and destination are the same: {0}", ex.Filename);
}
catch (Exception ex)
{
_logger.ErrorException("Failed to rename file: " + file.Path, ex);
}
}
if (renamed.Any())

@ -0,0 +1,14 @@
using System;
namespace NzbDrone.Core.MediaFiles
{
public class SameFilenameException : Exception
{
public String Filename { get; set; }
public SameFilenameException(string message, string filename) : base(message)
{
Filename = filename;
}
}
}

@ -234,6 +234,7 @@
<Compile Include="Download\EpisodeGrabbedEvent.cs" />
<Compile Include="MediaFiles\Events\SeriesRenamedEvent.cs" />
<Compile Include="MediaFiles\RenameEpisodeFileService.cs" />
<Compile Include="MediaFiles\SameFilenameException.cs" />
<Compile Include="MediaFiles\UpgradeMediaFileService.cs" />
<Compile Include="MetadataSource\Trakt\TraktCommunicationException.cs" />
<Compile Include="Notifications\Email\TestEmailCommand.cs" />

@ -35,7 +35,7 @@ namespace NzbDrone.Host.AccessControl
private void RegisterUrl(int portNumber)
{
var arguments = String.Format("http add urlacl http://*:{0}/ user=EVERYONE", portNumber);
var arguments = String.Format("http add urlacl http://*:{0}/ sddl=D:(A;;GX;;;S-1-1-0)", portNumber);
RunNetsh(arguments);
}

@ -77,6 +77,14 @@
<SpecificVersion>False</SpecificVersion>
<HintPath>..\packages\Microsoft.AspNet.SignalR.Owin.1.1.2\lib\net40\Microsoft.AspNet.SignalR.Owin.dll</HintPath>
</Reference>
<Reference Include="Microsoft.Owin, Version=1.1.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35, processorArchitecture=MSIL">
<SpecificVersion>False</SpecificVersion>
<HintPath>..\packages\Microsoft.Owin.1.1.0-beta2\lib\net40\Microsoft.Owin.dll</HintPath>
</Reference>
<Reference Include="Microsoft.Owin.Host.HttpListener, Version=1.1.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35, processorArchitecture=MSIL">
<SpecificVersion>False</SpecificVersion>
<HintPath>..\packages\Microsoft.Owin.Host.HttpListener.1.1.0-beta2\lib\net40\Microsoft.Owin.Host.HttpListener.dll</HintPath>
</Reference>
<Reference Include="Microsoft.Owin.Hosting, Version=1.1.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35, processorArchitecture=MSIL">
<SpecificVersion>False</SpecificVersion>
<HintPath>..\packages\Microsoft.Owin.Hosting.1.1.0-beta2\lib\net40\Microsoft.Owin.Hosting.dll</HintPath>

Loading…
Cancel
Save