Skip to content
This repository

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse code

Merge pull request #1 from mattadams/master

Install directly into /data/data/app.namespace
  • Loading branch information...
commit 1d603779b71d16093d05001b7d680c861de32b0c 2 parents 3ae75e7 + f63fb72
Dale  Harvey authored July 07, 2011
46  src/com/couchbase/libcouch/CouchInstaller.java
@@ -34,7 +34,7 @@
34 34
 	final static String TAG = "CouchDB";
35 35
 
36 36
 	public static String dataPath() {
37  
-		return "/data/data/" + appNamespace + "/cache";
  37
+		return "/data/data/" + appNamespace;
38 38
 	}
39 39
 	public static String externalPath() {
40 40
 		return Environment.getExternalStorageDirectory() + "/Android/data/" + appNamespace;
@@ -46,17 +46,28 @@ public static String indexFile() {
46 46
 	public static void doInstall(String url, String pkg, Handler handler, CouchService service)
47 47
 		throws IOException {
48 48
 
49  
-		// WARNING: This deleted any previously installed couchdb data
50  
-		// and binaries stored on the sdcard to keep in line with usual
51  
-		// android app behaviour. However there doesnt look to be a way to protect
52  
-		// ourselves from wiping the entire sdcard with a typo, so just be
53  
-		// careful
54  
-		File couchDir = new File(dataPath() + "/couchdb");
55  
-		if (couchDir.exists()) {
56  
-			deleteDirectory(couchDir);
57  
-		}
58  
-
59  
-		if(!(new File(dataPath() + "/" + pkg + ".installedfiles")).exists()) {
  49
+		if(!checkInstalled(pkg)) {
  50
+		    /*
  51
+	         * WARNING: the following two stanzas delete any previously installed 
  52
+	         * CouchDB and Erlang binaries stored in the app data space.  It isn't
  53
+	         * usually possible (in a non-rooted or emulated environment) to hurt
  54
+	         * other data directories but one must be especially careful when carrying
  55
+	         * out this sort of operation on external storage where there are no ways
  56
+	         * of protecting ourselves from wiping the entire SD card with a typo. 
  57
+	         */
  58
+		    
  59
+		    File couchDir = new File(dataPath() + "/couchdb");
  60
+		    
  61
+		    if (couchDir.exists()) {
  62
+		        deleteDirectory(couchDir);
  63
+		    }
  64
+
  65
+		    File erlangDir = new File(dataPath() + "/erlang");
  66
+		    
  67
+		    if (erlangDir.exists()) {
  68
+		        deleteDirectory(erlangDir);
  69
+		    }
  70
+		    
60 71
 			installPackage(url, pkg, handler, service);
61 72
 		}
62 73
 
@@ -189,7 +200,10 @@ private static void installPackage(String baseUrl, String pkg, Handler handler,
189 200
 		}
190 201
 		iLOWriter.close();
191 202
 
192  
-		// Write out full list of all installed files + file modes
  203
+		/*
  204
+		 * Write out full list of all installed files + file modes (the data in this file
  205
+		 * only represents the most recently installed release)
  206
+		 */
193 207
 		iLOWriter = new FileWriter(indexFile());
194 208
 
195 209
 		for (String file : allInstalledFiles) {
@@ -220,8 +234,8 @@ private static void installPackage(String baseUrl, String pkg, Handler handler,
220 234
 	}
221 235
 
222 236
 	/*
223  
-	 * Verifies that CouchDB is installed by checking the package files we
224  
-	 * write on installation + the data directory on the sd card
  237
+	 * Verifies that requested version of CouchDB is installed by checking for the presence of
  238
+	 * the package files we write upon installation in the data directory of the app.
225 239
 	 */
226 240
 	public static boolean checkInstalled(String pkg) {
227 241
 
@@ -230,7 +244,7 @@ public static boolean checkInstalled(String pkg) {
230 244
 			return false;
231 245
 		}
232 246
 
233  
-		return true;//new File(couchPath()).exists();
  247
+		return true;
234 248
 	}
235 249
 
236 250
 	/*

0 notes on commit 1d60377

Please sign in to comment.
Something went wrong with that request. Please try again.