public void AddFile(String url, String fileName) { Tracer.Trace("Adding '{0}'", url); var fileRecord = new FileDatabaseRecord(url, fileName); _fileDatabase.AddOrReplaceFile(fileRecord); }
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 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); } }