/// <summary> /// Clear data file, close any data stream pool, change password and re-create data factory /// </summary> public void ChangePassword(string password, EngineSettings settings) { if (settings.Password == password) { return; } // empty data file this.SetLength(0, FileOrigin.Data); // close all streams _dataPool.Dispose(); // delete data file _dataFactory.Delete(); settings.Password = password; // new datafile will be created with new password _dataFactory = settings.CreateDataFactory(); // create stream pool _dataPool = new StreamPool(_dataFactory, false); // get initial data file length _dataLength = -PAGE_SIZE; }
public void Dispose() { // dispose queue (wait finish) if (_queue.IsValueCreated) { _queue.Value.Dispose(); } // get stream length from writer - is safe because only this instance // can change file size var delete = _logFactory.Exists() && _logPool.Writer.Length == 0; // dispose Stream pools _dataPool.Dispose(); _logPool.Dispose(); ENSURE(_dataFactory.IsLocked() == false, "datafile must be released"); ENSURE(_dataFactory.IsLocked() == false, "logfile must be released"); if (delete) { _logFactory.Delete(); } // other disposes _cache.Dispose(); }
public void Dispose() { _pool.Dispose(); _factory.Delete(); }