mirror of https://github.com/lidarr/Lidarr
Fixed: Performance issue when scanning large root folder
This commit is contained in:
parent
1e98f01524
commit
52011e3bc8
|
@ -149,6 +149,13 @@ namespace NzbDrone.Common.Disk
|
|||
}
|
||||
}
|
||||
|
||||
public bool FolderEmpty(string path)
|
||||
{
|
||||
Ensure.That(path, () => path).IsValidPath();
|
||||
|
||||
return _fileSystem.Directory.EnumerateFileSystemEntries(path).Empty();
|
||||
}
|
||||
|
||||
public string[] GetDirectories(string path)
|
||||
{
|
||||
Ensure.That(path, () => path).IsValidPath();
|
||||
|
|
|
@ -22,6 +22,7 @@ namespace NzbDrone.Common.Disk
|
|||
bool FileExists(string path);
|
||||
bool FileExists(string path, StringComparison stringComparison);
|
||||
bool FolderWritable(string path);
|
||||
bool FolderEmpty(string path);
|
||||
string[] GetDirectories(string path);
|
||||
string[] GetFiles(string path, SearchOption searchOption);
|
||||
long GetFolderSize(string path);
|
||||
|
|
|
@ -9,6 +9,7 @@ using FluentAssertions;
|
|||
using Moq;
|
||||
using NUnit.Framework;
|
||||
using NzbDrone.Common.Disk;
|
||||
using NzbDrone.Common.Extensions;
|
||||
using NzbDrone.Core.DecisionEngine;
|
||||
using NzbDrone.Core.MediaFiles;
|
||||
using NzbDrone.Core.MediaFiles.TrackImport;
|
||||
|
@ -139,7 +140,7 @@ namespace NzbDrone.Core.Test.MediaFiles.DiskScanServiceTests
|
|||
ExceptionVerification.ExpectedWarns(1);
|
||||
|
||||
Mocker.GetMock<IDiskProvider>()
|
||||
.Verify(v => v.FolderExists(_artist.Path), Times.Never());
|
||||
.Verify(v => v.GetFiles(_artist.Path, SearchOption.AllDirectories), Times.Never());
|
||||
|
||||
Mocker.GetMock<IMediaFileTableCleanupService>()
|
||||
.Verify(v => v.Clean(It.IsAny<string>(), It.IsAny<List<string>>()), Times.Never());
|
||||
|
|
|
@ -95,25 +95,28 @@ namespace NzbDrone.Core.MediaFiles
|
|||
return;
|
||||
}
|
||||
|
||||
if (!_diskProvider.FolderExists(rootFolder.Path))
|
||||
{
|
||||
_logger.Warn("Root folder {0} doesn't exist.", rootFolder.Path);
|
||||
var folderExists = _diskProvider.FolderExists(folder);
|
||||
|
||||
var skippedArtists = _artistService.GetArtists(artistIds);
|
||||
skippedArtists.ForEach(x => _eventAggregator.PublishEvent(new ArtistScanSkippedEvent(x, ArtistScanSkippedReason.RootFolderDoesNotExist)));
|
||||
return;
|
||||
if (!folderExists)
|
||||
{
|
||||
if (!_diskProvider.FolderExists(rootFolder.Path))
|
||||
{
|
||||
_logger.Warn("Artists' root folder ({0}) doesn't exist.", rootFolder);
|
||||
var skippedArtists = _artistService.GetArtists(artistIds);
|
||||
skippedArtists.ForEach(x => _eventAggregator.PublishEvent(new ArtistScanSkippedEvent(x, ArtistScanSkippedReason.RootFolderDoesNotExist)));
|
||||
return;
|
||||
}
|
||||
|
||||
if (_diskProvider.FolderEmpty(rootFolder.Path))
|
||||
{
|
||||
_logger.Warn("Artists' root folder ({0}) is empty.", rootFolder);
|
||||
var skippedArtists = _artistService.GetArtists(artistIds);
|
||||
skippedArtists.ForEach(x => _eventAggregator.PublishEvent(new ArtistScanSkippedEvent(x, ArtistScanSkippedReason.RootFolderIsEmpty)));
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
if (_diskProvider.GetDirectories(rootFolder.Path).Empty())
|
||||
{
|
||||
_logger.Warn("Root folder {0} is empty.", rootFolder.Path);
|
||||
|
||||
var skippedArtists = _artistService.GetArtists(artistIds);
|
||||
skippedArtists.ForEach(x => _eventAggregator.PublishEvent(new ArtistScanSkippedEvent(x, ArtistScanSkippedReason.RootFolderIsEmpty)));
|
||||
return;
|
||||
}
|
||||
|
||||
if (!_diskProvider.FolderExists(folder))
|
||||
if (!folderExists)
|
||||
{
|
||||
_logger.Debug("Specified scan folder ({0}) doesn't exist.", folder);
|
||||
|
||||
|
|
Loading…
Reference in New Issue