/// <summary> /// Initialize a new or existing index using an internal Sqlite database. /// </summary> /// <param name="indexFile">Path and filename.</param> /// <param name="settings">Deduplication settings.</param> /// <param name="callbacks">Object containing callback functions for writing, reading, and deleting chunks.</param> public DedupeLibrary(string indexFile, DedupeSettings settings, DedupeCallbacks callbacks) { if (String.IsNullOrEmpty(indexFile)) { throw new ArgumentNullException(nameof(indexFile)); } if (settings == null) { throw new ArgumentNullException(nameof(settings)); } if (callbacks == null) { throw new ArgumentNullException(nameof(callbacks)); } _Settings = settings; _Callbacks = callbacks; _IndexFile = DedupeCommon.SanitizeString(indexFile); _Database = new SqliteProvider(_IndexFile); InitializeIndex(); }
/// <summary> /// Initialize an existing index using an external database. Tables must be created ahead of time. /// </summary> /// <param name="database">Database provider implemented using the Database.DbProvider class.</param> /// <param name="settings">Deduplication settings.</param> /// <param name="callbacks">Object containing callback functions for writing, reading, and deleting chunks.</param> public DedupeLibrary(DbProvider database, DedupeSettings settings, DedupeCallbacks callbacks) { if (database == null) { throw new ArgumentNullException(nameof(database)); } if (settings == null) { throw new ArgumentNullException(nameof(settings)); } if (callbacks == null) { throw new ArgumentNullException(nameof(callbacks)); } _Database = database; _Settings = settings; _Callbacks = callbacks; InitializeIndex(); }