Fixed a bug in CleanupBookmarks where the Except was deleting all files because the path separators didn't match. (#932)
This commit is contained in:
parent
920f187cd4
commit
7eaa0248c3
2 changed files with 81 additions and 6 deletions
|
@ -174,16 +174,17 @@ namespace API.Services.Tasks
|
|||
/// </summary>
|
||||
public async Task CleanupBookmarks()
|
||||
{
|
||||
// Search all files in bookmarks/
|
||||
// except bookmark files and delete those
|
||||
// Search all files in bookmarks/ except bookmark files and delete those
|
||||
var bookmarkDirectory =
|
||||
(await _unitOfWork.SettingsRepository.GetSettingAsync(ServerSettingKey.BookmarkDirectory)).Value;
|
||||
var allBookmarkFiles = _directoryService.GetFiles(bookmarkDirectory, searchOption: SearchOption.AllDirectories);
|
||||
var allBookmarkFiles = _directoryService.GetFiles(bookmarkDirectory, searchOption: SearchOption.AllDirectories).Select(f => _directoryService.FileSystem.Path.GetFullPath(f));
|
||||
var bookmarks = (await _unitOfWork.UserRepository.GetAllBookmarksAsync())
|
||||
.Select(b => _directoryService.FileSystem.Path.Join(bookmarkDirectory,
|
||||
b.FileName));
|
||||
.Select(b => _directoryService.FileSystem.Path.GetFullPath(_directoryService.FileSystem.Path.Join(bookmarkDirectory,
|
||||
b.FileName)));
|
||||
|
||||
var filesToDelete = allBookmarkFiles.Except(bookmarks);
|
||||
|
||||
var filesToDelete = allBookmarkFiles.ToList().Except(bookmarks).ToList();
|
||||
_logger.LogDebug("[Bookmarks] Bookmark cleanup wants to delete {Count} files", filesToDelete.Count());
|
||||
|
||||
_directoryService.DeleteFiles(filesToDelete);
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue