ReplaceDatabase with Zipped Files

57 views
Skip to first unread message

Julio Albuquerque

unread,
Jul 29, 2015, 10:08:11 AM7/29/15
to Couchbase Mobile
hello
I'm trying to use the ReplaceDatabase function using zipped files, but get the error illegal operation.
Has anyone done this?
The file must be zipped into any specific software?
I used the PKZIP command line.

var assetsZip = this.Assets.Open ("db.zip");
 manager
.ReplaceDatabase ("db", assetsZip, false);
 db
= manager.GetExistingDatabase ("db");


Julio.

Jens Alfke

unread,
Jul 29, 2015, 12:53:41 PM7/29/15
to mobile-c...@googlegroups.com

On Jul 29, 2015, at 7:08 AM, Julio Albuquerque <jcezar.al...@gmail.com> wrote:

I'm trying to use the ReplaceDatabase function using zipped files, but get the error illegal operation.

Um, you forgot to unzip the file first…

—Jens

Julio Albuquerque

unread,
Jul 29, 2015, 1:32:10 PM7/29/15
to Couchbase Mobile, jcezar.al...@gmail.com
I did not understand then!
The function says the file should be compressed and contain all the necessary database files.
I'm using 
Couchbase.Lite .NET version 1.1.0.1 with Xamarin Android.

See the function parameters:

Manager.ReplaceDatabase( string name, Stream compressedStream, bool autoRename)

In parameter compressedStream information is: The zip stream containing all of the files required by the DB.
Summary: Replaces or installs a database from a zipped DB folder structure.

In my zip file contains three files: db.cblite, db.cblite-shm and db.cblite-wal.

Jens Alfke

unread,
Jul 29, 2015, 1:43:37 PM7/29/15
to mobile-c...@googlegroups.com, jcezar.al...@gmail.com

On Jul 29, 2015, at 10:32 AM, Julio Albuquerque <jcezar.al...@gmail.com> wrote:

The function says the file should be compressed and contain all the necessary database files.

The database should be compacted — you should call Database.compact( ) to remove obsolete revisions or attachments, so the file doesn’t contain unnecessary data.

You can zip the files too, of course, but make sure to unzip them before telling Couchbase Lite to install them.

—Jens

Jim Borden

unread,
Aug 16, 2015, 11:32:24 AM8/16/15
to Couchbase Mobile, jcezar.al...@gmail.com
Yes, Couchbase Lite for .NET has a convenience API to use zipped files with the correct directory setup.  There are a number of unit tests to check this functionality.  Try using a different zip software I guess?  Many of the manufacturers make some proprietary changes in the way they implement zip structure, and you might have created one that ICSharp cannot handle.
Reply all
Reply to author
Forward
0 new messages