public void Scan(Folder folder) { if (folder == null) throw new ArgumentNullException("folder"); var dir = _fileSystem.GetDirectory(folder.Path); if (!dir.Exists) return; var filter = _keyValueStore.Get<string>("autoadd.filter"); var files = dir.GetFiles(filter, folder.RecursiveSearch ? SearchScope.Recursive : SearchScope.Current); foreach (var file in files) { var fileName = file.Path.GetFilename().FullPath; if (!string.IsNullOrEmpty(folder.Pattern) && !Regex.IsMatch(fileName, folder.Pattern)) continue; if (_autoAddRepository.GetHistoryByPath(file.Path.FullPath) != null) continue; AddFile(file); if (folder.RemoveSourceFile) { file.Delete(); } } }
public Folder CreateFolder(Folder folder) { if (folder == null) throw new ArgumentNullException("folder"); _autoAddRepository.CreateFolder(folder); return folder; }
public void UpdateFolder(Folder folder) { var query = @"update AutoAdd_Folder set Path = @Path, Pattern = @Pattern, RemoveSourceFile = @RemoveSourceFile, RecursiveSearch = @RecursiveSearch, AutoStart = @AutoStart where Id = @Id"; _connection.Execute(query, folder); }
public void CreateFolder(Folder folder) { var query = @"insert into AutoAdd_Folder (Path, Pattern, RemoveSourceFile, RecursiveSearch, AutoStart) values (@Path, @Pattern, @RemoveSourceFile, @RecursiveSearch, @AutoStart); select last_insert_rowid();"; folder.Id = _connection.Query<int>(query, folder).First(); }
public void UpdateFolder(Folder folder) { if (folder == null) throw new ArgumentNullException("folder"); _autoAddRepository.UpdateFolder(folder); }