From: David A. Velasco Date: Tue, 26 Jun 2012 07:52:32 +0000 (+0200) Subject: Fixed duplication of some files in local database due to differences in remote and... X-Git-Tag: oc-android-1.4.3~334 X-Git-Url: http://git.linex4red.de/pub/Android/ownCloud.git/commitdiff_plain/91225458c1c52614b0254badd9b5e25ebe880f8e?hp=--cc Fixed duplication of some files in local database due to differences in remote and local URL encoding --- 91225458c1c52614b0254badd9b5e25ebe880f8e diff --git a/AndroidManifest.xml b/AndroidManifest.xml index 905391e7..c66c64d6 100644 --- a/AndroidManifest.xml +++ b/AndroidManifest.xml @@ -18,7 +18,7 @@ --> + android:versionName="0.1.134B" xmlns:android="http://schemas.android.com/apk/res/android"> diff --git a/src/eu/alefzero/owncloud/datamodel/OCFile.java b/src/eu/alefzero/owncloud/datamodel/OCFile.java index 3a720b97..ca454d15 100644 --- a/src/eu/alefzero/owncloud/datamodel/OCFile.java +++ b/src/eu/alefzero/owncloud/datamodel/OCFile.java @@ -60,7 +60,7 @@ public class OCFile implements Parcelable, Comparable { 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 { 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), "/"); } /** diff --git a/src/eu/alefzero/owncloud/files/services/InstantUploadService.java b/src/eu/alefzero/owncloud/files/services/InstantUploadService.java index 8c8ee31f..9ac0411b 100644 --- a/src/eu/alefzero/owncloud/files/services/InstantUploadService.java +++ b/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) { diff --git a/src/eu/alefzero/owncloud/ui/activity/FileDisplayActivity.java b/src/eu/alefzero/owncloud/ui/activity/FileDisplayActivity.java index d19cd3cf..ec4def42 100644 --- a/src/eu/alefzero/owncloud/ui/activity/FileDisplayActivity.java +++ b/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(); diff --git a/src/eu/alefzero/webdav/WebdavClient.java b/src/eu/alefzero/webdav/WebdavClient.java index 907de67c..0a231c08 100644 --- a/src/eu/alefzero/webdav/WebdavClient.java +++ b/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());