From: David A. Velasco Date: Mon, 30 Jul 2012 10:02:34 +0000 (+0200) Subject: Granted that accounts different only in port number won't mix their files in the... X-Git-Tag: oc-android-1.4.3~227 X-Git-Url: http://git.linex4red.de/pub/Android/ownCloud.git/commitdiff_plain/c06007b98a004ff7b03b08ef1e9136614ee15290?ds=inline Granted that accounts different only in port number won't mix their files in the same local folder --- diff --git a/AndroidManifest.xml b/AndroidManifest.xml index 597c27b2..4c27b14f 100644 --- a/AndroidManifest.xml +++ b/AndroidManifest.xml @@ -18,7 +18,7 @@ --> + android:versionName="0.1.190B" xmlns:android="http://schemas.android.com/apk/res/android"> diff --git a/src/eu/alefzero/owncloud/datamodel/FileDataStorageManager.java b/src/eu/alefzero/owncloud/datamodel/FileDataStorageManager.java index b6fa918c..f0d0db25 100644 --- a/src/eu/alefzero/owncloud/datamodel/FileDataStorageManager.java +++ b/src/eu/alefzero/owncloud/datamodel/FileDataStorageManager.java @@ -27,6 +27,7 @@ import java.util.Vector; import eu.alefzero.owncloud.db.ProviderMeta; import eu.alefzero.owncloud.db.ProviderMeta.ProviderTableMeta; +import eu.alefzero.owncloud.files.services.FileDownloader; import android.accounts.Account; import android.content.ContentProviderClient; import android.content.ContentProviderOperation; @@ -378,8 +379,7 @@ public class FileDataStorageManager implements DataStorageManager { .getColumnIndex(ProviderTableMeta.FILE_STORAGE_PATH))); if (file.getStoragePath() == null) { // try to find existing file and bind it with current account - File sdCard = Environment.getExternalStorageDirectory(); - File f = new File(sdCard.getAbsolutePath() + "/owncloud/" + mAccount.name + file.getRemotePath()); + File f = new File(FileDownloader.getSavePath(mAccount.name) + file.getRemotePath()); if (f.exists()) file.setStoragePath(f.getAbsolutePath()); } diff --git a/src/eu/alefzero/owncloud/files/services/FileDownloader.java b/src/eu/alefzero/owncloud/files/services/FileDownloader.java index af327a56..b0dd2b26 100644 --- a/src/eu/alefzero/owncloud/files/services/FileDownloader.java +++ b/src/eu/alefzero/owncloud/files/services/FileDownloader.java @@ -13,6 +13,7 @@ import android.app.PendingIntent; import android.app.Service; import android.content.ContentValues; import android.content.Intent; +import android.net.Uri; import android.os.Environment; import android.os.Handler; import android.os.HandlerThread; @@ -82,14 +83,16 @@ public class FileDownloader extends Service implements OnDatatransferProgressLis } } - public static final String getSavePath() { + public static final String getSavePath(String accountName) { File sdCard = Environment.getExternalStorageDirectory(); - return sdCard.getAbsolutePath() + "/owncloud/"; + return sdCard.getAbsolutePath() + "/owncloud/" + Uri.encode(accountName, "@"); + // URL encoding is an 'easy fix' to overcome that NTFS and FAT32 don't allow ":" in file names, that can be in the accountName since 0.1.190B } - public static final String getTemporalPath() { + public static final String getTemporalPath(String accountName) { File sdCard = Environment.getExternalStorageDirectory(); - return sdCard.getAbsolutePath() + "/owncloud.tmp/"; + return sdCard.getAbsolutePath() + "/owncloud/tmp/" + Uri.encode(accountName, "@"); + // URL encoding is an 'easy fix' to overcome that NTFS and FAT32 don't allow ":" in file names, that can be in the accountName since 0.1.190B } @Override @@ -155,7 +158,7 @@ public class FileDownloader extends Service implements OnDatatransferProgressLis /// download will be in a temporal file - File tmpFile = new File(getTemporalPath() + mAccount.name + mFilePath); + File tmpFile = new File(getTemporalPath(mAccount.name) + mFilePath); /// create status notification to show the download progress mNotification = new Notification(R.drawable.icon, getString(R.string.downloader_download_in_progress_ticker), System.currentTimeMillis()); @@ -175,7 +178,7 @@ public class FileDownloader extends Service implements OnDatatransferProgressLis File newFile = null; try { if (wdc.downloadFile(mRemotePath, tmpFile)) { - newFile = new File(getSavePath() + mAccount.name + mFilePath); + newFile = new File(getSavePath(mAccount.name) + mFilePath); newFile.getParentFile().mkdirs(); boolean moved = tmpFile.renameTo(newFile); diff --git a/src/eu/alefzero/owncloud/ui/activity/AuthenticatorActivity.java b/src/eu/alefzero/owncloud/ui/activity/AuthenticatorActivity.java index 60f8c889..5c9d093e 100644 --- a/src/eu/alefzero/owncloud/ui/activity/AuthenticatorActivity.java +++ b/src/eu/alefzero/owncloud/ui/activity/AuthenticatorActivity.java @@ -20,6 +20,7 @@ package eu.alefzero.owncloud.ui.activity; import java.net.MalformedURLException; import java.net.URL; +import java.net.URLEncoder; import android.accounts.Account; import android.accounts.AccountAuthenticatorActivity; @@ -167,6 +168,9 @@ public class AuthenticatorActivity extends AccountAuthenticatorActivity String username = username_text.getText().toString().trim(); String accountName = username + "@" + url.getHost(); + if (url.getPort() >= 0) { + accountName += ":" + url.getPort(); + } Account account = new Account(accountName, AccountAuthenticator.ACCOUNT_TYPE); AccountManager accManager = AccountManager.get(this);