* add letter bar with no links * use lucene for search, add paged search results * add search index version * index library_name; rebuild index when folder is missing * maintain index as local movies change * fix tests * maintain index as local shows change * maintain index as plex movies change * maintain index as plex shows change * code cleanup * add duplicate filter to search * add links to letter bar * code cleanup
53 lines
1.6 KiB
C#
53 lines
1.6 KiB
C#
using System;
|
|
using System.Collections.Generic;
|
|
using System.IO;
|
|
using System.Threading.Tasks;
|
|
using ErsatzTV.Core.Domain;
|
|
using ErsatzTV.Core.Interfaces.Metadata;
|
|
using LanguageExt;
|
|
using static LanguageExt.Prelude;
|
|
|
|
namespace ErsatzTV.Core.Metadata
|
|
{
|
|
public class LocalFileSystem : ILocalFileSystem
|
|
{
|
|
public Unit EnsureFolderExists(string folder)
|
|
{
|
|
if (!Directory.Exists(folder))
|
|
{
|
|
Directory.CreateDirectory(folder);
|
|
}
|
|
|
|
return Unit.Default;
|
|
}
|
|
|
|
public DateTime GetLastWriteTime(string path) =>
|
|
Try(File.GetLastWriteTimeUtc(path)).IfFail(() => DateTime.MinValue);
|
|
|
|
public bool IsLibraryPathAccessible(LibraryPath libraryPath) =>
|
|
Directory.Exists(libraryPath.Path);
|
|
|
|
public IEnumerable<string> ListSubdirectories(string folder) =>
|
|
Try(Directory.EnumerateDirectories(folder)).IfFail(new List<string>());
|
|
|
|
public IEnumerable<string> ListFiles(string folder) =>
|
|
Try(Directory.EnumerateFiles(folder, "*", SearchOption.TopDirectoryOnly)).IfFail(new List<string>());
|
|
|
|
public bool FileExists(string path) => File.Exists(path);
|
|
public Task<byte[]> ReadAllBytes(string path) => File.ReadAllBytesAsync(path);
|
|
|
|
public Unit CopyFile(string source, string destination)
|
|
{
|
|
string directory = Path.GetDirectoryName(destination) ?? string.Empty;
|
|
if (!Directory.Exists(directory))
|
|
{
|
|
Directory.CreateDirectory(directory);
|
|
}
|
|
|
|
File.Copy(source, destination, true);
|
|
|
|
return Unit.Default;
|
|
}
|
|
}
|
|
}
|