static private void CheckFiles(String databaseFileName) { var fileDatabase = new FileDatabase(databaseFileName); int count = fileDatabase.GetFileCount(); var baseDirectory = Path.GetDirectoryName(databaseFileName); var webCrawler = new WebCrawler(baseDirectory); for (var i = 0; i < count; i++) { var fileDatabaseRecord = fileDatabase.GetFile(i); if (fileDatabaseRecord.Size < 0) { var webHeaders = webCrawler.DownloadHeaders(fileDatabaseRecord.Url); fileDatabaseRecord.Modify(webHeaders.LastModified, webHeaders.ContentLength, webHeaders.ContentType, "", false, false); } var fileName = Path.Combine(baseDirectory, fileDatabaseRecord.FileName); var fileInfo = new FileInfo(fileName); if (fileInfo.Exists) { fileDatabaseRecord.Available = true; fileDatabaseRecord.OutOfDate = (fileInfo.Length != fileDatabaseRecord.Size) || (fileInfo.LastWriteTime != fileDatabaseRecord.Modified); } fileDatabase.AddOrReplaceFile(fileDatabaseRecord); } }
private static void CheckFiles(String databaseFileName) { var fileDatabase = new FileDatabase(databaseFileName); int count = fileDatabase.GetFileCount(); var baseDirectory = Path.GetDirectoryName(databaseFileName); var webCrawler = new WebCrawler(baseDirectory); for (var i = 0; i < count; i++) { var fileDatabaseRecord = fileDatabase.GetFile(i); if (fileDatabaseRecord.Size < 0) { var webHeaders = webCrawler.DownloadHeaders(fileDatabaseRecord.Url); fileDatabaseRecord.Modify(webHeaders.LastModified, webHeaders.ContentLength, webHeaders.ContentType, "", false, false); } var fileName = Path.Combine(baseDirectory, fileDatabaseRecord.FileName); var fileInfo = new FileInfo(fileName); if (fileInfo.Exists) { fileDatabaseRecord.Available = true; fileDatabaseRecord.OutOfDate = (fileInfo.Length != fileDatabaseRecord.Size) || (fileInfo.LastWriteTime != fileDatabaseRecord.Modified); } fileDatabase.AddOrReplaceFile(fileDatabaseRecord); } }
static private void UpdateFiles(String databaseFileName) { var fileDatabase = new FileDatabase(databaseFileName); var webCrawler = new WebCrawler(Path.GetDirectoryName(databaseFileName)); while (true) { var fileDatabaseRecord = fileDatabase.GetNextNotAvailableOrOutOfDateFile(); if (null == fileDatabaseRecord) { return; } webCrawler.UpdateFile(fileDatabaseRecord); } }
private static void UpdateFiles(String databaseFileName) { var fileDatabase = new FileDatabase(databaseFileName); var webCrawler = new WebCrawler(Path.GetDirectoryName(databaseFileName)); while (true) { var fileDatabaseRecord = fileDatabase.GetNextNotAvailableOrOutOfDateFile(); if (null == fileDatabaseRecord) { return; } webCrawler.UpdateFile(fileDatabaseRecord); } }