/// <exception cref="Couchbase.Lite.CouchbaseLiteException"></exception> private void ReplaceDatabase(string databaseName, InputStream databaseStream, IEnumerator <KeyValuePair <string, InputStream> > attachmentStreams) { try { Database database = GetDatabase(databaseName); string dstAttachmentsPath = database.GetAttachmentStorePath(); OutputStream destStream = new FileOutputStream(new FilePath(database.GetPath())); StreamUtils.CopyStream(databaseStream, destStream); FilePath attachmentsFile = new FilePath(dstAttachmentsPath); FileDirUtils.DeleteRecursive(attachmentsFile); attachmentsFile.Mkdirs(); if (attachmentStreams != null) { StreamUtils.CopyStreamsToFolder(attachmentStreams, attachmentsFile); } database.Open(); database.ReplaceUUIDs(); } catch (FileNotFoundException e) { Log.E(Database.Tag, string.Empty, e); throw new CouchbaseLiteException(Status.InternalServerError); } catch (IOException e) { Log.E(Database.Tag, string.Empty, e); throw new CouchbaseLiteException(Status.InternalServerError); } }
/// <exception cref="System.IO.IOException"></exception> protected internal virtual void StartCBLite() { string serverPath = GetServerPath(); FilePath serverPathFile = new FilePath(serverPath); FileDirUtils.DeleteRecursive(serverPathFile); serverPathFile.Mkdir(); manager = new Manager(new FilePath(GetRootDirectory(), "test"), Manager.DefaultOptions ); }
public virtual void ReplaceDatabase(string databaseName, FilePath databaseFile, FilePath attachmentsDirectory) { Database database = GetDatabase(databaseName); string dstAttachmentsPath = database.GetAttachmentStorePath(); FilePath destFile = new FilePath(database.GetPath()); FileDirUtils.CopyFile(databaseFile, destFile); FilePath attachmentsFile = new FilePath(dstAttachmentsPath); FileDirUtils.DeleteRecursive(attachmentsFile); attachmentsFile.Mkdirs(); if (attachmentsDirectory != null) { FileDirUtils.CopyFolder(attachmentsDirectory, attachmentsFile); } database.ReplaceUUIDs(); }
/// <exception cref="System.IO.IOException"></exception> protected internal virtual void StartCBLite() { LiteTestContext context = new LiteTestContext(); string serverPath = context.GetRootDirectory().GetAbsolutePath(); FilePath serverPathFile = new FilePath(serverPath); FileDirUtils.DeleteRecursive(serverPathFile); serverPathFile.Mkdir(); Manager.EnableLogging(Log.Tag, Log.Verbose); Manager.EnableLogging(Log.TagSync, Log.Verbose); Manager.EnableLogging(Log.TagQuery, Log.Verbose); Manager.EnableLogging(Log.TagView, Log.Verbose); Manager.EnableLogging(Log.TagChangeTracker, Log.Verbose); Manager.EnableLogging(Log.TagBlobStore, Log.Verbose); Manager.EnableLogging(Log.TagDatabase, Log.Verbose); Manager.EnableLogging(Log.TagListener, Log.Verbose); Manager.EnableLogging(Log.TagMultiStreamWriter, Log.Verbose); Manager.EnableLogging(Log.TagRemoteRequest, Log.Verbose); Manager.EnableLogging(Log.TagRouter, Log.Verbose); manager = new Manager(context, Manager.DefaultOptions); }
public void ReplaceDatabase(string databaseName, FilePath databaseFile, FilePath attachmentsDirectory) { try { Database database = GetDatabase(databaseName); string dstAttachmentsPath = database.GetAttachmentStorePath(); FilePath destFile = new FilePath(database.GetPath()); FileDirUtils.CopyFile(databaseFile, destFile); FilePath attachmentsFile = new FilePath(dstAttachmentsPath); FileDirUtils.DeleteRecursive(attachmentsFile); attachmentsFile.Mkdirs(); if (attachmentsDirectory != null) { FileDirUtils.CopyFolder(attachmentsDirectory, attachmentsFile); } database.ReplaceUUIDs(); } catch (IOException e) { Log.E(Database.Tag, string.Empty, e); throw new CouchbaseLiteException(Status.InternalServerError); } }
public void TestGetDatabaseNameFromPath() { Assert.AreEqual("baz", FileDirUtils.GetDatabaseNameFromPath("foo/bar/baz.cblite")); }
/// <exception cref="System.Exception"></exception> public virtual void TestGetDatabaseNameFromPath() { NUnit.Framework.Assert.AreEqual("baz", FileDirUtils.GetDatabaseNameFromPath("foo/bar/baz.cblite" )); }