private static LibrarySyncDetail.LocalLibrarySyncDetail GetLocalLibrarySyncDetail(Library library) { WPFDoEvents.AssertThisCodeIs_NOT_RunningInTheUIThread(); LibrarySyncDetail.LocalLibrarySyncDetail local_library_sync_detail = new LibrarySyncDetail.LocalLibrarySyncDetail(); List <PDFDocument> pdf_documents = library.PDFDocuments_IncludingDeleted; foreach (PDFDocument pdf_document in pdf_documents) { try { ++local_library_sync_detail.total_files_in_library; // Don't tally the deleted documents bool deleted = pdf_document.Deleted; if (deleted) { ++local_library_sync_detail.total_files_in_library_deleted; continue; } // We can only really tally up the documents that exist locally local_library_sync_detail.total_library_size += pdf_document.DocumentSizeInBytes; } catch (Exception ex) { Logging.Error(ex, "There was an error tallying up the local library sync detail for '{0}'.", pdf_document.Fingerprint); } } return(local_library_sync_detail); }
private static LibrarySyncDetail.LocalLibrarySyncDetail GetLocalLibrarySyncDetail(Library library, bool tally_library_storage_size) { WPFDoEvents.AssertThisCodeIs_NOT_RunningInTheUIThread(); LibrarySyncDetail.LocalLibrarySyncDetail local_library_sync_detail = new LibrarySyncDetail.LocalLibrarySyncDetail(); List <PDFDocument> pdf_documents = library.PDFDocuments_IncludingDeleted; foreach (PDFDocument pdf_document in pdf_documents) { try { ++local_library_sync_detail.total_files_in_library; // Don't tally the deleted documents bool deleted = pdf_document.Deleted; if (deleted) { ++local_library_sync_detail.total_files_in_library_deleted; continue; } if (tally_library_storage_size) { // We can only really tally up the documents that exist locally local_library_sync_detail.total_library_size += pdf_document.GetDocumentSizeInBytes(); } else { // fake it: take about 10KB per document, unless we already determined (and cached) the document size before. // This spares us the large overhead of querying the file system for every document in the // (possibly huge) library. local_library_sync_detail.total_library_size += pdf_document.GetDocumentSizeInBytes(uncached_document_storage_size_override: 10 * 1024); } } catch (Exception ex) { Logging.Error(ex, "There was an error tallying up the local library sync detail for '{0}'.", pdf_document.Fingerprint); } } return(local_library_sync_detail); }
private static LibrarySyncDetail.LocalLibrarySyncDetail GetLocalLibrarySyncDetail(Library library) { LibrarySyncDetail.LocalLibrarySyncDetail local_library_sync_detail = new LibrarySyncDetail.LocalLibrarySyncDetail(); List <PDFDocument> pdf_documents = library.PDFDocuments_IncludingDeleted; foreach (PDFDocument pdf_document in pdf_documents) { try { ++local_library_sync_detail.total_files_in_library; // Don't tally the deleted documents bool deleted = pdf_document.Deleted; if (deleted) { ++local_library_sync_detail.total_files_in_library_deleted; continue; } // We can only really tally up the documents that exist locally if (pdf_document.DocumentExists) { long document_size = (new FileInfo(pdf_document.DocumentPath)).Length; local_library_sync_detail.total_library_size += document_size; } } catch (Exception ex) { Logging.Error(ex, "There was an error tallying up the local library sync detail for '{0}'.", pdf_document.Fingerprint); } } return(local_library_sync_detail); }