mirror of
https://github.com/Kareadita/Kavita.git
synced 2025-07-09 03:04:19 -04:00
Scan library after we edit library folders, only if folders have differences.
This commit is contained in:
parent
219f6e675a
commit
0b486cdc08
@ -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…
x
Reference in New Issue
Block a user