Exemplo n.º 1
0
 /// <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);
     }
 }
Exemplo n.º 2
0
        /// <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
                                  );
        }
Exemplo n.º 3
0
        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();
        }
Exemplo n.º 4
0
        /// <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);
        }
Exemplo n.º 5
0
 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"));
 }
Exemplo n.º 7
0
 /// <exception cref="System.Exception"></exception>
 public virtual void TestGetDatabaseNameFromPath()
 {
     NUnit.Framework.Assert.AreEqual("baz", FileDirUtils.GetDatabaseNameFromPath("foo/bar/baz.cblite"
                                                                                 ));
 }