Inconsistent Permissions

I’m not sure whether it’s sonarr (or nzbget) but my final outputted files have inconsistent permissions. I want to be able to delete them via my mythv setup, so want a write “by anyone” permission on them.

Sometimes I get that, other times I get “by owner”. I don’t see a pattern. I’ve tried setting the chmod mask in sonarr to 0666, but that doesn’t seem to make a difference.

Any thoughts?

On the sorted files (in the series folder)?

As long as Sonarr is importing them then Sonarr would be the ones setting permissions, are you seeing errors in the logs?

Yes, the sorted files in the series folder.

The log is full of messages like this:

“Import failed, path does not exist or is not accessible by Sonarr: /media/nzb2/NZBGet/video/[ xxxxxxxxxxx ].S01E02.HDTV.x264.xxx” There seems to be a message for every show in my database? (There are 40,500 messages like that in my log file!)

Is nzbget extracting files to the sorted folder?
Did you set drone factory folder?

I’m pretty sure I am seeing the same thing and I think there are a few threads on the forums popping up that are related… Started happening since the last update on the 21st. It seemed intermittent at first, but now it’s happened on all episodes that have downloaded for the last 3 days.

Activity page shows all of them as having completed downloading, but have the yellow error icon next to them. Mousing over the icon gives: “Failed to import episode”

Looking through the logs I see this entry for each immediately after download is complete:

15-5-26 08:15:09.7|Warn|ImportApprovedEpisodes|Couldn't import episode /mnt/disc_1000_r5/Upload/Completed/Community.S06E12.PROPER.720p.WEBRip.x264-BATV[rarbg]/Community.S06E12.PROPER.720p.WEBRip.x264-BATV.mkv

System.UnauthorizedAccessException: Access to the path is denied.
  at System.IO.File.Move (System.String sourceFileName, System.String destFileName) [0x00000] in <filename unknown>:0 
  at NzbDrone.Common.Disk.DiskProviderBase.TransferFile (System.String source, System.String destination, TransferMode mode, Boolean overwrite) [0x0017f] in m:\BuildAgent\work\6c3239faf2b92630\src\NzbDrone.Common\Disk\DiskProviderBase.cs:285 
  at NzbDrone.Core.MediaFiles.EpisodeFileMovingService.TransferFile (NzbDrone.Core.MediaFiles.EpisodeFile episodeFile, NzbDrone.Core.Tv.Series series, System.Collections.Generic.List`1 episodes, System.String destinationFilename, TransferMode mode) [0x001b5] in m:\BuildAgent\work\6c3239faf2b92630\src\NzbDrone.Core\MediaFiles\EpisodeFileMovingService.cs:126 
  at NzbDrone.Core.MediaFiles.EpisodeFileMovingService.MoveEpisodeFile (NzbDrone.Core.MediaFiles.EpisodeFile episodeFile, NzbDrone.Core.Parser.Model.LocalEpisode localEpisode) [0x00055] in m:\BuildAgent\work\6c3239faf2b92630\src\NzbDrone.Core\MediaFiles\EpisodeFileMovingService.cs:68 
  at NzbDrone.Core.MediaFiles.UpgradeMediaFileService.UpgradeEpisodeFile (NzbDrone.Core.MediaFiles.EpisodeFile episodeFile, NzbDrone.Core.Parser.Model.LocalEpisode localEpisode, Boolean copyOnly) [0x00119] in m:\BuildAgent\work\6c3239faf2b92630\src\NzbDrone.Core\MediaFiles\UpgradeMediaFileService.cs:64 
  at NzbDrone.Core.MediaFiles.EpisodeImport.ImportApprovedEpisodes.Import (System.Collections.Generic.List`1 decisions, Boolean newDownload, NzbDrone.Core.Download.DownloadClientItem downloadClientItem) [0x0022c] in m:\BuildAgent\work\6c3239faf2b92630\src\NzbDrone.Core\MediaFiles\EpisodeImport\ImportApprovedEpisodes.cs:89 

Thereafter I see the following for each of the torrents every minute when the CDH runs:

15-5-26 08:16:27.1|Warn|ImportApprovedEpisodes|Couldn't import episode /mnt/disc_1000_r5/Upload/Completed/Community.S06E12.PROPER.720p.WEBRip.x264-BATV[rarbg]/Community.S06E12.PROPER.720p.WEBRip.x264-BATV.mkv

System.IO.IOException: Win32 IO returned ERROR_ALREADY_EXISTS. Path: 
  at System.IO.File.Move (System.String sourceFileName, System.String destFileName) [0x00000] in <filename unknown>:0 
  at NzbDrone.Common.Disk.DiskProviderBase.TransferFile (System.String source, System.String destination, TransferMode mode, Boolean overwrite) [0x0017f] in m:\BuildAgent\work\6c3239faf2b92630\src\NzbDrone.Common\Disk\DiskProviderBase.cs:285 
  at NzbDrone.Core.MediaFiles.EpisodeFileMovingService.TransferFile (NzbDrone.Core.MediaFiles.EpisodeFile episodeFile, NzbDrone.Core.Tv.Series series, System.Collections.Generic.List`1 episodes, System.String destinationFilename, TransferMode mode) [0x001b5] in m:\BuildAgent\work\6c3239faf2b92630\src\NzbDrone.Core\MediaFiles\EpisodeFileMovingService.cs:126 
  at NzbDrone.Core.MediaFiles.EpisodeFileMovingService.MoveEpisodeFile (NzbDrone.Core.MediaFiles.EpisodeFile episodeFile, NzbDrone.Core.Parser.Model.LocalEpisode localEpisode) [0x00055] in m:\BuildAgent\work\6c3239faf2b92630\src\NzbDrone.Core\MediaFiles\EpisodeFileMovingService.cs:68 
  at NzbDrone.Core.MediaFiles.UpgradeMediaFileService.UpgradeEpisodeFile (NzbDrone.Core.MediaFiles.EpisodeFile episodeFile, NzbDrone.Core.Parser.Model.LocalEpisode localEpisode, Boolean copyOnly) [0x00119] in m:\BuildAgent\work\6c3239faf2b92630\src\NzbDrone.Core\MediaFiles\UpgradeMediaFileService.cs:64 
  at NzbDrone.Core.MediaFiles.EpisodeImport.ImportApprovedEpisodes.Import (System.Collections.Generic.List`1 decisions, Boolean newDownload, NzbDrone.Core.Download.DownloadClientItem downloadClientItem) [0x0022c] in m:\BuildAgent\work\6c3239faf2b92630\src\NzbDrone.Core\MediaFiles\EpisodeImport\ImportApprovedEpisodes.cs:89 

When I go look at my TV Shows folder I see the files being copied into place, but none of my permissions or ownership settings that I have defined in Sonarr are being applied. I’ve set sonarr to apply 666 attributes and jrhelbert:jrhelbert for ownership, but I only see 644 and jrhelbert:nogroup being applies.

In addition, since Sonarr believe the import failed, it is not importing the episode nor is it informing anything I have listed under connections.

I’ve tried deleting the file from my TV Shows folder, but the same sequence of errors occurs and I end up with the same state.

Ubuntu 14.04.2 LTS
Linux server 3.13.0-53-generic #89-Ubuntu SMP Wed May 20 10:34:39 UTC 2015 x86_64 x86_64 x86_64 GNU/Linux
Mono JIT compiler version 4.0.1 (tarball Tue May 12 15:39:23 UTC 2015)
Sonarr 2.0.0.3154

Removed the file and let Sonarr try the import again with trace logging:
First import failed - http://pastebin.com/kWDmQZvY
Second (and thereafter) imports fail - http://pastebin.com/Fc1R84fU

My importing error ended up being an issue with transmission setting user/group and permissions that resulted in the user that Sonarr is running as not being able to access the files. Sonarr would then fail and none of the subsequent tasks would run… I’ve fixed the permissions from transmission. Sonarr would still give the “ERROR_ALREADY_EXISTS” error. I removed the files from my TV Shows folder and Sonarr then imported properly.

I’m still seeing the permissions issues, sometimes it’s applying the 666, but it still fails to set group…

15-5-26 09:42:09.8|Warn|MediaFileAttributeService|Unable to apply permissions to: /mnt/disc_2000/TV.Shows/Game.of.Thrones/Season.5/Game.of.Thrones.S05E07.The.Gift.mkv

NzbDrone.Mono.LinuxPermissionsException: Error setting file owner and/or group: EPERM
  at NzbDrone.Mono.DiskProvider.SetPermissions (System.String path, System.String mask, System.String user, System.String group) [0x00107] in m:\BuildAgent\work\6c3239faf2b92630\src\NzbDrone.Mono\DiskProvider.cs:117 
  at NzbDrone.Core.MediaFiles.MediaFileAttributeService.SetMonoPermissions (System.String path, System.String permissions) [0x0000e] in m:\BuildAgent\work\6c3239faf2b92630\src\NzbDrone.Core\MediaFiles\MediaFileAttributeService.cs:88

Unless you’re running a root giving files away is not possible, eventually we plan to remove the settings that allow you to change ownership because they don’t work in most cases.