public async void LoadIndexesAsync(ISonicCache cache) { var x = new MusicFolders(cache); await LoadIndexesOperation.RunAsync(() => x.GetAsync(SourcePolicy.Cache), e => { }); Indexes.StableMergeUpdate(x.Folders.First().Indexes); }
/// <summary>Initializes a new instance of the <see cref="MusicDataBase"/> class.</summary> /// <param name="rootFolder">The root folder.</param> /// <exception cref="FileNotFoundException">WebFolder missing!</exception> /// <exception cref="Exception"></exception> public MusicDataBase(string rootFolder) { this.LogVerbose("Initializing MusicDataBase"); RootFolder = rootFolder; ConfigFileName = FileSystem.Combine(rootFolder, "JukeBob.ini"); this.LogVerbose("Loading configuration {0}", ConfigFileName); Config = IniReader.FromFile(ConfigFileName); if (!Config.HasSection("MusicDataBase")) { throw new FileNotFoundException($"Missing configuration {ConfigFileName}!", ConfigFileName); } foreach (string folder in Config.ReadSection("MusicFolders", true)) { string f = Path.GetFullPath(folder); this.LogVerbose("MusicFolder {0} => {1}", folder, f); if (!Directory.Exists(f)) { throw new DirectoryNotFoundException(string.Format("MusicFolder {0} not found!", folder)); } MusicFolders.Include(f); } DataBasePath = GetFolderConfig("MusicDataBase", "DatabaseFolder", "database"); this.LogVerbose("Using Database path {0}", DataBasePath); try { ArtistArtFolder = GetFolderConfig("MusicDataBase", "ArtFolder", "art"); this.LogVerbose("ArtistArtFolder {0}", ArtistArtFolder); Directory.CreateDirectory(ArtistArtFolder); CacheFolder = GetFolderConfig("MusicDataBase", "CacheFolder", "cache"); this.LogVerbose("CacheFolder {0}", CacheFolder); Directory.CreateDirectory(CacheFolder); WebFolder = GetFolderConfig("MusicDataBase", "WebFolder", "web"); this.LogVerbose("WebFolder {0}", WebFolder); if (!File.Exists(FileSystem.Combine(WebFolder, "index.cwt"))) { throw new FileNotFoundException("WebFolder missing!"); } } catch (Exception ex) { throw new Exception(string.Format("Could not load configuration from {0}", ConfigFileName), ex); } }
public IndexesViewModel(ISonicCache cache) { LoadIndexesOperation = new LongRunningOperation(); LoadIndexesAsync(cache); RefreshCommand = new RelayCommand(async () => { ArbitraryContainer.Default.Resolve<INavigationService>().ClearPageCache(); var x = new MusicFolders(cache); await x.GetAsync(SourcePolicy.Refresh); Indexes.StableMergeUpdate(x.Folders.First().Indexes); }); DirectoryClickedCommand = new RelayCommand<MusicDirectory>( x => ArbitraryContainer.Default.Resolve<INavigationService>().Navigate(typeof(MusicDirectoryView), x)); }
private void RemoveMusicFolder() { MusicFolders.Remove(MusicSearchPath); DataService.SetSavedSearchFolders(MusicFolders); }
private void AddMusicFolder() { MusicSearchPath = DataService.OpenFolderBrowser(); MusicFolders.Add(MusicSearchPath); DataService.SetSavedSearchFolders(MusicFolders); }