Переглянути джерело

Fixed duplication of some files in local database due to differences in remote and local URL encoding

David A. Velasco 13 роки тому
батько
коміт
91225458c1

+ 1 - 1
AndroidManifest.xml

@@ -18,7 +18,7 @@
  -->
 <manifest package="eu.alefzero.owncloud"
     android:versionCode="1"
-    android:versionName="0.1.133B" xmlns:android="http://schemas.android.com/apk/res/android">
+    android:versionName="0.1.134B" xmlns:android="http://schemas.android.com/apk/res/android">
 
     <uses-permission android:name="android.permission.GET_ACCOUNTS" />
     <uses-permission android:name="android.permission.USE_CREDENTIALS" />

+ 3 - 2
src/eu/alefzero/owncloud/datamodel/OCFile.java

@@ -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), "/");
     }
 
     /**

+ 1 - 1
src/eu/alefzero/owncloud/files/services/InstantUploadService.java

@@ -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) {

+ 3 - 5
src/eu/alefzero/owncloud/ui/activity/FileDisplayActivity.java

@@ -106,7 +106,7 @@ public class FileDisplayActivity extends SherlockFragmentActivity implements
 
         // TODO: fix hack: workaround for bug in actionbar sherlock
         // it always shows indeterminate progress bar
-        if (android.os.Build.VERSION.SDK_INT >= android.os.Build.VERSION_CODES.ICE_CREAM_SANDWICH) {
+        if (android.os.Build.VERSION.SDK_INT >= android.os.Build.VERSION_CODES.HONEYCOMB) {
             requestWindowFeature(Window.FEATURE_INDETERMINATE_PROGRESS);
             setProgressBarIndeterminateVisibility(false);
         }
@@ -417,14 +417,12 @@ public class FileDisplayActivity extends SherlockFragmentActivity implements
                             // Figure out the path where the dir needs to be created
                             String path;
                             if (mCurrentDir == null) {
+                                // this is just a patch; we should ensure that mCurrentDir never is null
                                 if (!mStorageManager.fileExists("/")) {
                                     OCFile file = new OCFile("/");
                                     mStorageManager.saveFile(file);
-                                    mCurrentDir = mStorageManager.getFileByPath("/");
-                                } else {
-                                    Log.wtf("FileDisplay", "OMG NO!");
-                                    return;
                                 }
+                                mCurrentDir = mStorageManager.getFileByPath("/");
                             }
                             path = FileDisplayActivity.this.mCurrentDir.getRemotePath();
                             

+ 0 - 1
src/eu/alefzero/webdav/WebdavClient.java

@@ -85,7 +85,6 @@ public class WebdavClient extends HttpClient {
         GetMethod get = new GetMethod(mUri.toString()
                 + remoteFilepath.replace(" ", "%20"));
         */
-        
         GetMethod get = new GetMethod(mUri.toString() + remoteFilepath);
 
         // get.setHeader("Host", mUri.getHost());