I’ve configured sonarr and am trying to get it to play nice with sabnzbd for downloading. It is able to queue downloads, but it fails when trying to import the episode. I have a group that contains sonarr and my user, and am using this as the group owner for the directories in question: $ grep media_storage /etc/group media_storage:x:1001:me,sonarr
Here are the logs I see for a particular episode: Couldn't import episode /mnt/media_storage/downloads/sab/complete/Modern.Family.S07E03.The.Closet.Case.1080p.WEB-DL.DD5.1.H.264-Oosh/6AQufNByvtxqIcbyraCXu3wKaQrFMHAOAHlR0W3c51kLqv7dPaE.mkv: Access to the path "/mnt/media_storage/shows/Modern Family/Season 7" is denied. System.UnauthorizedAccessException: Access to the path "/mnt/media_storage/shows/Modern Family/Season 7" is denied. at System.IO.Directory.CreateDirectoriesInternal (System.String path) [0x00000] in <filename unknown>:0 at System.IO.Directory.CreateDirectory (System.String path) [0x00000] in <filename unknown>:0 at NzbDrone.Common.Disk.DiskProviderBase.CreateFolder (System.String path) [0x00000] in <filename unknown>:0 at NzbDrone.Core.MediaFiles.EpisodeFileMovingService.CreateFolder (System.String directoryName) [0x00000] in <filename unknown>:0 at NzbDrone.Core.MediaFiles.EpisodeFileMovingService.EnsureEpisodeFolder (NzbDrone.Core.MediaFiles.EpisodeFile episodeFile, NzbDrone.Core.Tv.Series series, Int32 seasonNumber, System.String filePath) [0x00000] in <filename unknown>:0 at NzbDrone.Core.MediaFiles.EpisodeFileMovingService.EnsureEpisodeFolder (NzbDrone.Core.MediaFiles.EpisodeFile episodeFile, NzbDrone.Core.Parser.Model.LocalEpisode localEpisode, System.String filePath) [0x00000] in <filename unknown>:0 at NzbDrone.Core.MediaFiles.EpisodeFileMovingService.MoveEpisodeFile (NzbDrone.Core.MediaFiles.EpisodeFile episodeFile, NzbDrone.Core.Parser.Model.LocalEpisode localEpisode) [0x00000] in <filename unknown>:0 at NzbDrone.Core.MediaFiles.UpgradeMediaFileService.UpgradeEpisodeFile (NzbDrone.Core.MediaFiles.EpisodeFile episodeFile, NzbDrone.Core.Parser.Model.LocalEpisode localEpisode, Boolean copyOnly) [0x00000] in <filename unknown>:0 at NzbDrone.Core.MediaFiles.EpisodeImport.ImportApprovedEpisodes.Import (System.Collections.Generic.List1 decisions, Boolean newDownload, NzbDrone.Core.Download.DownloadClientItem downloadClientItem) [0x00000] in <filename unknown>:0
However, I have the directories set with group ownership and 775 permissions: $ ls -l /mnt/media_storage/shows/ total 0 drwxrwxr-x 1 me media_storage 96 Apr 15 2015 Episodes drwxrwxr-x 1 me media_storage 116 Oct 29 02:05 Fargo drwxrwxr-x 1 sickbeard media_storage 142 Oct 29 01:17 Game of Thrones drwxrwxr-x 1 me media_storage 96 Apr 15 2015 Man Lab drwxrwxr-x 1 me media_storage 172 Apr 15 2015 Modern Family drwxrwxr-x 1 sickbeard media_storage 16 Oct 29 01:20 Mr. Robot drwxrwxr-x 1 sickbeard media_storage 166 Oct 29 01:17 Silicon Valley $ ls -l /mnt/media_storage/shows/Modern\ Family/ total 0 -rwxrwxr-x 1 me media_storage 0 Apr 15 2015 Icon♪ drwxrwxr-x 1 me media_storage 2026 May 11 2014 Season 01 drwxrwxr-x 1 me media_storage 2182 May 12 2014 Season 02 drwxrwxr-x 1 me media_storage 2030 May 12 2014 Season 03 drwxrwxr-x 1 me media_storage 2020 May 12 2014 Season 04 drwxrwxr-x 1 me media_storage 2000 Aug 16 2014 Season 05
Just to be sure I tried this to see if sonarr has access to create directories and confirmed that it does: $ pwd /mnt/media_storage/shows/Modern Family $ sudo -u sonarr mkdir test $ ls -l total 0 -rwxrwxr-x 1 me media_storage 0 Apr 15 2015 Icon♪ drwxrwxr-x 1 me media_storage 2026 May 11 2014 Season 01 drwxrwxr-x 1 me media_storage 2182 May 12 2014 Season 02 drwxrwxr-x 1 me media_storage 2030 May 12 2014 Season 03 drwxrwxr-x 1 me media_storage 2020 May 12 2014 Season 04 drwxrwxr-x 1 me media_storage 2000 Aug 16 2014 Season 05 drwxr-xr-x 1 sonarr sonarr 0 Oct 29 14:31 test
However, I did try changing the permissions on these directories to 777 and confirmed that this does work. Am I doing something wrong here? All my testing seems to indicate that sonarr should be able to write to these directories but I still get the message in the logs indicating that it doesn’t have access to the destination.
When you execute “ls” use “ls -la” that way we can see the permission in current directory and above. Those are the single and double dots you see at the top directory listing.
Also format your post (or post to hastebin), you can wrap blocks of text in `'s (tildes) to format it like the line above, as-is the OP is a big wall of text.
@subzero79 Thanks for letting me know, I provided the parent of the show directory as I knew this would include the show directory permissions which I thought would be the relevant bit.
From the show folder: $ ls -la total 316 drwxrwxr-x 1 jared media_storage 180 Oct 29 14:31 . drwxrwxrwx 1 root root 264 Oct 29 14:29 .. -rwxrwxr-x 1 jared media_storage 4096 May 31 02:15 ._.DS_Store -rwxrwxr-x 1 jared media_storage 10244 May 9 22:17 .DS_Store -rwxrwxr-x 1 jared media_storage 305369 May 31 02:15 ._Icon♪ -rwxrwxr-x 1 jared media_storage 0 Apr 15 2015 Icon♪ drwxrwxr-x 1 jared media_storage 2026 May 11 2014 Season 01 drwxrwxr-x 1 jared media_storage 2182 May 12 2014 Season 02 drwxrwxr-x 1 jared media_storage 2030 May 12 2014 Season 03 drwxrwxr-x 1 jared media_storage 2020 May 12 2014 Season 04 drwxrwxr-x 1 jared media_storage 2000 Aug 16 2014 Season 05 drwxrwxr-x 1 jared media_storage 60 Nov 17 2014 .sync drwxr-xr-x 1 sonarr sonarr 0 Oct 29 14:31 test @markus101 $ ps aux | grep mono sonarr 11895 2.3 1.8 1479872 342124 ? Ssl Oct28 83:44 mono /usr/lib/sonarr/NzbDrone.exe -nobrowser -data=/var/lib/sonarr me 32231 0.0 0.0 10732 2440 pts/0 S+ 15:37 0:00 grep mono
I don’t see ant inconsistency in your outputs.
Except I don’t see Season 07 folder, did you chop it out?
There is a Linux tool call tree that can display the folders hierarchically with permissions and owners, very useful.
check again that Sonarr user is in the group with “groups sonarr”
@subzero79 Thanks for the input. I did not chop the Season 7 directory. There actually is no Season 7 folder yet, this is the first episode of the season that has been downloaded and I have not configured Sonarr to create empty season directories. So presumably Sonarr should be creating the Season 7 directory, then moving the file.
I may have been mistaken, looking at the config I only see an option for creating empty series folders which I do have turned on. I would think it would simply create the season folder when it had the first episode, and looking at the trace info it looks like the exception is happening at “System.IO.Directory.CreateDirectory”, which would seem to indicate that it’s trying to create the directory for the season.
I went ahead and manually created the Season directory and I do get a slightly different error. This time it fails at System.IO.File.Copy. Message Couldn't import episode /mnt/media_storage/downloads/sab/complete/Modern.Family.S07E03.The.Closet.Case.1080p.WEB-DL.DD5.1.H.264-Oosh/6AQufNByvtxqIcbyraCXu3wKaQrFMHAOAHlR0W3c51kLqv7dPaE.mkv: Access to the path "/mnt/media_storage/downloads/sab/complete/Modern.Family.S07E03.The.Closet.Case.1080p.WEB-DL.DD5.1.H.264-Oosh/6AQufNByvtxqIcbyraCXu3wKaQrFMHAOAHlR0W3c51kLqv7dPaE.mkv" or "/mnt/media_storage/shows/Modern Family/Season 7/Modern Family - S07E03 - The Closet Case WEBDL-1080p.mkv.partial~" is denied. Exception System.UnauthorizedAccessException: Access to the path "/mnt/media_storage/downloads/sab/complete/Modern.Family.S07E03.The.Closet.Case.1080p.WEB-DL.DD5.1.H.264-Oosh/6AQufNByvtxqIcbyraCXu3wKaQrFMHAOAHlR0W3c51kLqv7dPaE.mkv" or "/mnt/media_storage/shows/Modern Family/Season 7/Modern Family - S07E03 - The Closet Case WEBDL-1080p.mkv.partial~" is denied. at System.IO.File.Copy (System.String sourceFileName, System.String destFileName, Boolean overwrite) [0x00000] in <filename unknown>:0 at NzbDrone.Common.Disk.DiskProviderBase.CopyFile (System.String source, System.String destination, Boolean overwrite) [0x00000] in <filename unknown>:0 at NzbDrone.Common.Disk.DiskTransferService.TryCopyFile (System.String sourcePath, System.String targetPath) [0x00000] in <filename unknown>:0
As a test I did the copy manually using “sudo -u sonarr cp” and then the paths specified in the message, and the copy does succeed.
Local filesystem, BTRFS. The system itself is Arch.
I started looking for known issues with System.IO.File.Copy and System.UnauthorizedAccessException getting thrown erroneously under Linux, since at this point it really seems like this setup should work, especially considering that I can “sudo -u sonarr” and perform everything sonarr is trying to do successfully. Looks like there might be some issues specific with Mono. See here:
I executed the following commands and then restarted Sonarr, and everything appears to now be working: sudo mkdir /etc/mono/registry sudo mkdir /etc/mono/registry/LocalMachine sudo chmod g+rwx /etc/mono/registry/ sudo chmod g+rwx /etc/mono/registry/LocalMachine
Given mono doesn’t seem to actually be writing anything to this directory, so maybe it just needed restarted. I’ll update if I find anything else.
I use btrfs under kernel 3.16 (debian) with mono 4.0.4. Sonarr runs inside a docker container and the source path is remote. Never had such issues, even with mono 3.10.
Good to know, it must something kernel upstream.
What kernel are you using?
The comments in stack overflow were made back in 2013 so it seems unlikely to me that this is some new issue, and it seems a little suspicious to me that the other commenter that had a problem with mono was also running Arch. I’ll probably play around with deleting those directories I created to see if it actually makes a difference. It could be that it just needed to be restarted for some reason but that’s a bit hard for me to believe, I’m fairly sure I restarted the process a couple different times after setting it up.