Scan library after we edit library folders, only if folders have differences.
This commit is contained in:
parent
219f6e675a
commit
0b486cdc08
1 changed files with 11 additions and 1 deletions
|
@ -159,14 +159,24 @@ namespace API.Controllers
|
||||||
public async Task<ActionResult> UpdateLibrary(UpdateLibraryDto libraryForUserDto)
|
public async Task<ActionResult> UpdateLibrary(UpdateLibraryDto libraryForUserDto)
|
||||||
{
|
{
|
||||||
var library = await _libraryRepository.GetLibraryForIdAsync(libraryForUserDto.Id);
|
var library = await _libraryRepository.GetLibraryForIdAsync(libraryForUserDto.Id);
|
||||||
|
|
||||||
|
var originalFolders = library.Folders.Select(x => x.Path);
|
||||||
|
var differenceBetweenFolders = originalFolders.Except(libraryForUserDto.Folders);
|
||||||
|
|
||||||
library.Name = libraryForUserDto.Name;
|
library.Name = libraryForUserDto.Name;
|
||||||
library.Folders = libraryForUserDto.Folders.Select(s => new FolderPath() {Path = s}).ToList();
|
library.Folders = libraryForUserDto.Folders.Select(s => new FolderPath() {Path = s}).ToList();
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
_libraryRepository.Update(library);
|
_libraryRepository.Update(library);
|
||||||
|
|
||||||
if (await _libraryRepository.SaveAllAsync())
|
if (await _libraryRepository.SaveAllAsync())
|
||||||
{
|
{
|
||||||
// TODO: We should probably call ScanLibrary after this
|
if (differenceBetweenFolders.Any())
|
||||||
|
{
|
||||||
|
BackgroundJob.Enqueue(() => _directoryService.ScanLibrary(library.Id));
|
||||||
|
}
|
||||||
|
|
||||||
return Ok();
|
return Ok();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue