37 lines
1.1 KiB
C#
37 lines
1.1 KiB
C#
using System.Threading;
|
|
using System.Threading.Tasks;
|
|
using Microsoft.Extensions.Hosting;
|
|
using MediaBrowser.Controller.Library;
|
|
using MediaBrowser.Model.Configuration;
|
|
|
|
namespace Jellyfin.Plugin.Webdav
|
|
{
|
|
/// <summary>
|
|
/// Hosted service that registers the WebDAV source as a virtual folder on server startup.
|
|
/// </summary>
|
|
public class WebDavHostedService : IHostedService
|
|
{
|
|
private readonly ILibraryManager _libraryManager;
|
|
|
|
public WebDavHostedService(ILibraryManager libraryManager)
|
|
{
|
|
_libraryManager = libraryManager;
|
|
}
|
|
|
|
public async Task StartAsync(CancellationToken cancellationToken)
|
|
{
|
|
// Register a virtual folder for WebDAV remote library
|
|
var options = new LibraryOptions
|
|
{
|
|
EnableInvertFolderHierarchy = false
|
|
};
|
|
|
|
// Name must match plugin display name
|
|
await _libraryManager
|
|
.AddVirtualFolder("WebDAV", null, options, true)
|
|
.ConfigureAwait(false);
|
|
}
|
|
|
|
public Task StopAsync(CancellationToken cancellationToken) => Task.CompletedTask;
|
|
}
|
|
} |