Ejemplo n.º 1
0
        public void AddFile(String url, String fileName)
        {
            Tracer.Trace("Adding '{0}'", url);

            var fileRecord = new FileDatabaseRecord(url, fileName);

            _fileDatabase.AddOrReplaceFile(fileRecord);
        }
Ejemplo n.º 2
0
        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);
            }
        }
Ejemplo n.º 3
0
        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);
            }
        }