예제 #1
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);
            }
        }
예제 #2
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);
            }
        }
예제 #3
0
        public void UpdateFile(String url) // TODO: remove this overload?
        {
            var fileRecord = _fileDatabase.GetFile(url);

            if (null == fileRecord)
            {
                throw new Exception("Not in database");
            }

            UpdateFile(fileRecord);
        }
예제 #4
0
        private static void ListFiles(String databaseFileName)
        {
            var fileDatabase = new FileDatabase(databaseFileName);

            int count = fileDatabase.GetFileCount();
            Console.WriteLine("{0} files in database:", count);
            Console.WriteLine();

            for (var i = 0; i < count; i++)
            {
                var fileDatabaseRecord = fileDatabase.GetFile(i);

                Console.WriteLine("Url:       {0}", fileDatabaseRecord.Url);
                Console.WriteLine("FileName:  {0}", fileDatabaseRecord.FileName);
                Console.WriteLine("Modified:  {0}", fileDatabaseRecord.Modified);
                Console.WriteLine("Size:      {0}", fileDatabaseRecord.Size);
                Console.WriteLine("Type:      {0}", fileDatabaseRecord.Type);
                Console.WriteLine("Checksum:  {0}", fileDatabaseRecord.Checksum);
                Console.WriteLine("Available: {0}", fileDatabaseRecord.Available);
                Console.WriteLine("OutOfDate: {0}", fileDatabaseRecord.OutOfDate);
                Console.WriteLine();
            }
        }
예제 #5
0
        static private void ListFiles(String databaseFileName)
        {
            var fileDatabase = new FileDatabase(databaseFileName);

            int count = fileDatabase.GetFileCount();

            Console.WriteLine("{0} files in database:", count);
            Console.WriteLine();

            for (var i = 0; i < count; i++)
            {
                var fileDatabaseRecord = fileDatabase.GetFile(i);

                Console.WriteLine("Url:       {0}", fileDatabaseRecord.Url);
                Console.WriteLine("FileName:  {0}", fileDatabaseRecord.FileName);
                Console.WriteLine("Modified:  {0}", fileDatabaseRecord.Modified);
                Console.WriteLine("Size:      {0}", fileDatabaseRecord.Size);
                Console.WriteLine("Type:      {0}", fileDatabaseRecord.Type);
                Console.WriteLine("Checksum:  {0}", fileDatabaseRecord.Checksum);
                Console.WriteLine("Available: {0}", fileDatabaseRecord.Available);
                Console.WriteLine("OutOfDate: {0}", fileDatabaseRecord.OutOfDate);
                Console.WriteLine();
            }
        }