Fixed duplication of some files in local database due to differences in remote and...
authorDavid A. Velasco <dvelasco@solidgear.es>
Tue, 26 Jun 2012 07:52:32 +0000 (09:52 +0200)
committerDavid A. Velasco <dvelasco@solidgear.es>
Tue, 26 Jun 2012 07:52:32 +0000 (09:52 +0200)
AndroidManifest.xml
src/eu/alefzero/owncloud/datamodel/OCFile.java
src/eu/alefzero/owncloud/files/services/InstantUploadService.java
src/eu/alefzero/owncloud/ui/activity/FileDisplayActivity.java
src/eu/alefzero/webdav/WebdavClient.java

index 905391e..c66c64d 100644 (file)
@@ -18,7 +18,7 @@
  -->\r
 <manifest package="eu.alefzero.owncloud"\r
     android:versionCode="1"\r
-    android:versionName="0.1.133B" xmlns:android="http://schemas.android.com/apk/res/android">\r
+    android:versionName="0.1.134B" xmlns:android="http://schemas.android.com/apk/res/android">\r
 \r
     <uses-permission android:name="android.permission.GET_ACCOUNTS" />\r
     <uses-permission android:name="android.permission.USE_CREDENTIALS" />\r
index 3a720b9..ca454d1 100644 (file)
@@ -60,7 +60,7 @@ public class OCFile implements Parcelable, Comparable<OCFile> {
     public OCFile(String path) {
         resetData();
         mNeedsUpdating = false;
-        // dvelasco: let's make mandatory that mRemotePath is a valid URL always; this will make our life easier with the URL-encoding/decoding
+        /// dvelasco: the encoding / decoding problem should be completely translated to WebdavClient & WebdavEntry, but at this moment we are in a little hurry
         if (path != null && path.length() > 0) {
             try {
                 new URL("http://silly.test.com:8888" + path);
@@ -68,7 +68,8 @@ public class OCFile implements Parcelable, Comparable<OCFile> {
                 throw new RuntimeException("Trying to create a OCFile with a non valid remote path: " + path , e);
             }
         } else throw new RuntimeException("Trying to create a OCFile with a non valid remote path: " + path);
-        mRemotePath = path;
+        // save encoded paths have a problem: normalization; this is a quick&dirty fix to avoid duplications
+        mRemotePath = Uri.encode(Uri.decode(path), "/");
     }
 
     /**
index 8c8ee31..9ac0411 100644 (file)
@@ -148,7 +148,7 @@ public class InstantUploadService extends Service {
                 try {
                     status = wdc.executeMethod(mkcol);
                     Log.e(TAG, "mkcol returned " + status);
-                    wdc.putFile(filepath, INSTANT_UPLOAD_DIR + "/" + filename, mimetype);
+                    wdc.putFile(filepath, INSTANT_UPLOAD_DIR + "/" + Uri.encode(filename), mimetype);
                 } catch (HttpException e) {
                     e.printStackTrace();
                 } catch (IOException e) {
index d19cd3c..ec4def4 100644 (file)
@@ -106,7 +106,7 @@ public class FileDisplayActivity extends SherlockFragmentActivity implements
 \r
         // TODO: fix hack: workaround for bug in actionbar sherlock\r
         // it always shows indeterminate progress bar\r
-        if (android.os.Build.VERSION.SDK_INT >= android.os.Build.VERSION_CODES.ICE_CREAM_SANDWICH) {\r
+        if (android.os.Build.VERSION.SDK_INT >= android.os.Build.VERSION_CODES.HONEYCOMB) {\r
             requestWindowFeature(Window.FEATURE_INDETERMINATE_PROGRESS);\r
             setProgressBarIndeterminateVisibility(false);\r
         }\r
@@ -417,14 +417,12 @@ public class FileDisplayActivity extends SherlockFragmentActivity implements
                             // Figure out the path where the dir needs to be created\r
                             String path;\r
                             if (mCurrentDir == null) {\r
+                                // this is just a patch; we should ensure that mCurrentDir never is null\r
                                 if (!mStorageManager.fileExists("/")) {\r
                                     OCFile file = new OCFile("/");\r
                                     mStorageManager.saveFile(file);\r
-                                    mCurrentDir = mStorageManager.getFileByPath("/");\r
-                                } else {\r
-                                    Log.wtf("FileDisplay", "OMG NO!");\r
-                                    return;\r
                                 }\r
+                                mCurrentDir = mStorageManager.getFileByPath("/");\r
                             }\r
                             path = FileDisplayActivity.this.mCurrentDir.getRemotePath();\r
                             \r
index 907de67..0a231c0 100644 (file)
@@ -85,7 +85,6 @@ public class WebdavClient extends HttpClient {
         GetMethod get = new GetMethod(mUri.toString()\r
                 + remoteFilepath.replace(" ", "%20"));\r
         */\r
-        \r
         GetMethod get = new GetMethod(mUri.toString() + remoteFilepath);\r
 \r
         // get.setHeader("Host", mUri.getHost());\r