LibraryFileSystemDataSource

class LibraryFileSystemDataSource(library: PdfLibrary, documentsDirectory: File, documentHandler: (DocumentSource) -> Boolean? = null) : LibraryDataSource

A library data source that indexes all documents in a specified directory. This class will automatically add and remove files from the library based on changes in the directory.

Constructors

Link copied to clipboard
constructor(library: PdfLibrary, documentsDirectory: File, documentHandler: (DocumentSource) -> Boolean? = null)

Properties

Link copied to clipboard

Allowed file extensions for indexing. Defaults to just contain only "pdf". Note, at the time of release, this is only tested with PDF files. You might have PDF files without proper extension, in which case you can set this to null or an empty set.

Link copied to clipboard

Specifies whether the data source should only act on changes that are explicitly provided to it, rather than having reindex the whole directory. Set this property to true if you are able to specify which changes took place in the documents directory, thus avoiding the overhead of rescanning the directory when indexing. Use with didAddOrModifyDocumentAtPath and didRemoveDocumentAtPath methods. You still need to index the library afterwards with PdfLibrary.updateIndexFromDataSource.

Functions

Link copied to clipboard
fun cleanup()

Cleanup resources when the data source is no longer needed.

Link copied to clipboard

Notifies the data source that a document was added or modified to the documents directory. If the file does not exist in the documents directory, then this method does nothing.

Link copied to clipboard

Notifies the data source that a document was removed from the documents directory.

Link copied to clipboard

Asks the data source for a document source with the specified UID.

Link copied to clipboard

Returns a descriptor with some metadata for the document UID, if it has been requested for indexing.

Link copied to clipboard
open override fun libraryDidFinishIndexingDocument(uid: String, success: Boolean)

Called after the library indexes a document.

Link copied to clipboard
open override fun libraryDidRemoveDocument(uid: String)

Called after the library removes a document from its index.

Link copied to clipboard
open override fun libraryWillBeginIndexing()

Notifies the data source that the library is about to begin the indexing process. Perform any required setup here.

Link copied to clipboard

Asks the data source for the UIDs of the documents to be indexed by the library. This method should not return any UIDs that are already indexed, or they will be reindexed. This is useful in cases when the document was modified, and its contents changed and therefore need the index to be updated as well.

Link copied to clipboard

Asks the data source for the UIDs for documents to be removed. This method will be called by the library at the start of its indexing process to allow for removal of any non-existing documents.