41 lines
1.3 KiB
C#
41 lines
1.3 KiB
C#
/*
|
|
* Jellyfin.Plugin.Webdav
|
|
* Copyright (C) 2025 Jellyfin contributors
|
|
* Licensed under GPLv3
|
|
*/
|
|
namespace Jellyfin.Plugin.Webdav
|
|
{
|
|
using System.Threading;
|
|
using System.Threading.Tasks;
|
|
using MediaBrowser.Controller.Library;
|
|
using MediaBrowser.Model.Configuration;
|
|
using Microsoft.Extensions.Hosting;
|
|
|
|
/// <summary>
|
|
/// Hosted service that registers the WebDAV cache as a virtual folder on startup.
|
|
/// </summary>
|
|
public class WebDavHostedService : IHostedService
|
|
{
|
|
private readonly ILibraryManager _libraryManager;
|
|
|
|
/// <summary>
|
|
/// Initializes a new instance of the <see cref="WebDavHostedService"/> class.
|
|
/// </summary>
|
|
/// <param name="libraryManager">The library manager.</param>
|
|
public WebDavHostedService(ILibraryManager libraryManager)
|
|
{
|
|
_libraryManager = libraryManager;
|
|
}
|
|
|
|
/// <inheritdoc/>
|
|
public async Task StartAsync(CancellationToken cancellationToken)
|
|
{
|
|
var options = new LibraryOptions();
|
|
|
|
await _libraryManager.AddVirtualFolder("WebDAV", null, options, true).ConfigureAwait(false);
|
|
}
|
|
|
|
/// <inheritdoc/>
|
|
public Task StopAsync(CancellationToken cancellationToken) => Task.CompletedTask;
|
|
}
|
|
} |