mirror of
https://github.com/Readarr/Readarr
synced 2026-04-21 12:21:08 +02:00
Merge 64fcd5e90b into 0b79d3000d
This commit is contained in:
commit
5f978398ad
1 changed files with 50 additions and 0 deletions
|
|
@ -88,6 +88,19 @@ public void Scan(List<string> folders = null, FilterFilesType filter = FilterFil
|
|||
{
|
||||
authorIds = new List<int>();
|
||||
}
|
||||
else
|
||||
{
|
||||
folders = new List<string>();
|
||||
foreach (var authorId in authorIds)
|
||||
{
|
||||
var author = _authorService.GetAuthor(authorId);
|
||||
|
||||
if (author != null)
|
||||
{
|
||||
folders.Add(author.Path);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
var mediaFileList = new List<IFileInfo>();
|
||||
|
||||
|
|
@ -130,6 +143,25 @@ public void Scan(List<string> folders = null, FilterFilesType filter = FilterFil
|
|||
{
|
||||
_logger.Debug("Specified scan folder ({0}) doesn't exist.", folder);
|
||||
|
||||
if (_configService.CreateEmptyAuthorFolders)
|
||||
{
|
||||
if (_configService.DeleteEmptyFolders)
|
||||
{
|
||||
_logger.Debug("Not creating missing author folder: {0} because delete empty author folders is enabled", folder);
|
||||
}
|
||||
else
|
||||
{
|
||||
_logger.Debug("Creating missing author folder: {0}", folder);
|
||||
|
||||
_diskProvider.CreateFolder(folder);
|
||||
SetPermissions(folder);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
_logger.Debug("Author folder doesn't exist: {0}", rootFolder.Path);
|
||||
}
|
||||
|
||||
CleanMediaFiles(folder, new List<string>());
|
||||
continue;
|
||||
}
|
||||
|
|
@ -298,6 +330,24 @@ public List<string> FilterPaths(string basePath, IEnumerable<string> paths)
|
|||
.ToList();
|
||||
}
|
||||
|
||||
private void SetPermissions(string path)
|
||||
{
|
||||
if (!_configService.SetPermissionsLinux)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
try
|
||||
{
|
||||
_diskProvider.SetPermissions(path, _configService.ChmodFolder, _configService.ChownGroup);
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
_logger.Warn(ex, "Unable to apply permissions to: " + path);
|
||||
_logger.Debug(ex, ex.Message);
|
||||
}
|
||||
}
|
||||
|
||||
public List<IFileInfo> FilterFiles(string basePath, IEnumerable<IFileInfo> files)
|
||||
{
|
||||
return files.Where(file => !ExcludedSubFoldersRegex.IsMatch(basePath.GetRelativePath(file.FullName)))
|
||||
|
|
|
|||
Loading…
Reference in a new issue