internal async Task <Folder> EnsureLibraryFolder(string path, bool createIfNeeded) { var existingFolder = FindFolders(path).FirstOrDefault(); if (existingFolder != null) { return(existingFolder); } if (!createIfNeeded) { return(null); } Directory.CreateDirectory(path); var libraryOptions = new LibraryOptions { PathInfos = new[] { new MediaPathInfo { Path = path } }, EnableRealtimeMonitor = false, SaveLocalMetadata = true }; var name = _localizationManager.GetLocalizedString("Collections"); await _libraryManager.AddVirtualFolder(name, CollectionTypeOptions.BoxSets, libraryOptions, true).ConfigureAwait(false); return(FindFolders(path).First()); }
internal Task EnsureLibraryFolder(string path, string name) { var existingFolders = _libraryManager .RootFolder .Children .OfType <Folder>() .Where(i => _fileSystem.AreEqual(path, i.Path) || _fileSystem.ContainsSubPath(i.Path, path)) .ToList(); if (existingFolders.Count > 0) { return(Task.CompletedTask); } _fileSystem.CreateDirectory(path); var libraryOptions = new LibraryOptions { PathInfos = new[] { new MediaPathInfo { Path = path } }, EnablePhotos = true, EnableRealtimeMonitor = false, SaveLocalMetadata = true }; if (string.IsNullOrWhiteSpace(name)) { name = _localizationManager.GetLocalizedString("HeaderCameraUploads"); } return(_libraryManager.AddVirtualFolder(name, CollectionType.HomeVideos, libraryOptions, true)); }
internal async Task <Folder> EnsureLibraryFolder(string path, string name) { var existingFolders = FindFolders(path) .ToList(); if (existingFolders.Count > 0) { return(existingFolders[0]); } _fileSystem.CreateDirectory(path); var libraryOptions = new LibraryOptions { PathInfos = new[] { new MediaPathInfo { Path = path } }, EnableRealtimeMonitor = false, SaveLocalMetadata = true }; if (string.IsNullOrWhiteSpace(name)) { name = _localizationManager.GetLocalizedString("Collections"); } await _libraryManager.AddVirtualFolder(name, CollectionType.BoxSets, libraryOptions, true).ConfigureAwait(false); return(FindFolders(path).First()); }
/// <summary> /// Posts the specified request. /// </summary> /// <param name="request">The request.</param> public Task Post(AddVirtualFolder request) { var libraryOptions = request.LibraryOptions ?? new LibraryOptions(); if (request.Paths != null && request.Paths.Length > 0) { libraryOptions.PathInfos = request.Paths.Select(i => new MediaPathInfo { Path = i }).ToArray(); } return(_libraryManager.AddVirtualFolder(request.Name, request.CollectionType, libraryOptions, request.RefreshLibrary)); }
public async Task <ActionResult> AddVirtualFolder( [FromQuery] string?name, [FromQuery] CollectionTypeOptions?collectionType, [FromQuery, ModelBinder(typeof(CommaDelimitedArrayModelBinder))] string[] paths, [FromBody] AddVirtualFolderDto?libraryOptionsDto, [FromQuery] bool refreshLibrary = false) { var libraryOptions = libraryOptionsDto?.LibraryOptions ?? new LibraryOptions(); if (paths != null && paths.Length > 0) { libraryOptions.PathInfos = paths.Select(i => new MediaPathInfo(i)).ToArray(); } await _libraryManager.AddVirtualFolder(name, collectionType, libraryOptions, refreshLibrary).ConfigureAwait(false); return(NoContent()); }
/// <summary> /// Posts the specified request. /// </summary> /// <param name="request">The request.</param> public void Post(AddVirtualFolder request) { _libraryManager.AddVirtualFolder(request.Name, request.CollectionType, request.Paths, request.RefreshLibrary); }
/// <summary> /// Posts the specified request. /// </summary> /// <param name="request">The request.</param> public void Post(AddVirtualFolder request) { var libraryOptions = request.LibraryOptions ?? new LibraryOptions(); _libraryManager.AddVirtualFolder(request.Name, request.CollectionType, request.Paths, libraryOptions, request.RefreshLibrary); }