Browse Source

Merge pull request #509 from nextcloud/autoUploadWrongDirectoryCreated

fix wrong creation of folder during auto upload
Andy Scherzinger 8 năm trước cách đây
mục cha
commit
d2f1d38896

+ 2 - 2
AndroidManifest.xml

@@ -20,8 +20,8 @@
 -->
 <manifest xmlns:android="http://schemas.android.com/apk/res/android"
     package="com.owncloud.android"
-    android:versionCode="10040101"
-    android:versionName="1.4.1 RC1">
+    android:versionCode="10040102"
+    android:versionName="1.4.1 RC2">
 
     <uses-sdk
         android:minSdkVersion="14"

+ 2 - 6
src/com/owncloud/android/services/SyncedFolderJobService.java

@@ -46,8 +46,6 @@ public class SyncedFolderJobService extends JobService {
 
     public static final String LOCAL_PATH = "filePath";
     public static final String REMOTE_PATH = "remotePath";
-    public static final String DATE_TAKEN = "dateTaken";
-    public static final String SUBFOLDER_BY_DATE = "subfolderByDate";
     public static final String ACCOUNT = "account";
     public static final String UPLOAD_BEHAVIOUR = "uploadBehaviour";
 
@@ -61,9 +59,7 @@ public class SyncedFolderJobService extends JobService {
         Context context = MainApp.getAppContext();
         PersistableBundle bundle = params.getExtras();
         String filePath = bundle.getString(LOCAL_PATH);
-        String remoteFolder = bundle.getString(REMOTE_PATH);
-        Long dateTaken = bundle.getLong(DATE_TAKEN);
-        Boolean subfolderByDate = bundle.getInt(SUBFOLDER_BY_DATE) == 1;
+        String remotePath = bundle.getString(REMOTE_PATH);
         Account account = AccountUtils.getOwnCloudAccountByName(context, bundle.getString(ACCOUNT));
         Integer uploadBehaviour = bundle.getInt(UPLOAD_BEHAVIOUR);
 
@@ -80,7 +76,7 @@ public class SyncedFolderJobService extends JobService {
                     context,
                     account,
                     filePath,
-                    FileStorageUtils.getInstantUploadFilePath(remoteFolder, file.getName(), dateTaken, subfolderByDate),
+                    remotePath,
                     uploadBehaviour,
                     mimeType,
                     true,           // create parent folder if not existent

+ 5 - 3
src/com/owncloud/android/services/observer/SyncedFolderObserver.java

@@ -14,6 +14,7 @@ import com.owncloud.android.MainApp;
 import com.owncloud.android.datamodel.SyncedFolder;
 import com.owncloud.android.lib.common.utils.Log_OC;
 import com.owncloud.android.services.SyncedFolderJobService;
+import com.owncloud.android.utils.FileStorageUtils;
 import com.owncloud.android.utils.RecursiveFileObserver;
 
 import java.io.File;
@@ -48,11 +49,12 @@ class SyncedFolderObserver extends RecursiveFileObserver {
             PersistableBundle bundle = new PersistableBundle();
             // TODO extract
             bundle.putString(SyncedFolderJobService.LOCAL_PATH, path);
-            bundle.putString(SyncedFolderJobService.REMOTE_PATH, syncedFolder.getRemotePath() + "/" + temp.getName());
-            bundle.putLong(SyncedFolderJobService.DATE_TAKEN, new Date().getTime());
+            bundle.putString(SyncedFolderJobService.REMOTE_PATH, FileStorageUtils.getInstantUploadFilePath(
+                                                                 syncedFolder.getRemotePath(), temp.getName(),
+                                                                 new Date().getTime(),
+                                                                 syncedFolder.getSubfolderByDate()));
             bundle.putString(SyncedFolderJobService.ACCOUNT, syncedFolder.getAccount());
             bundle.putInt(SyncedFolderJobService.UPLOAD_BEHAVIOUR, syncedFolder.getUploadAction());
-            bundle.putInt(SyncedFolderJobService.SUBFOLDER_BY_DATE, syncedFolder.getSubfolderByDate() ? 1 : 0);
 
             JobScheduler js = (JobScheduler) context.getSystemService(Context.JOB_SCHEDULER_SERVICE);
 

+ 2 - 4
src/com/owncloud/android/ui/adapter/ExpandableUploadListAdapter.java

@@ -229,9 +229,8 @@ public class ExpandableUploadListAdapter extends BaseExpandableListAdapter imple
 
             // remote path to parent folder
             TextView pathTextView = (TextView) view.findViewById(R.id.upload_remote_path);
-            String remoteParentPath = upload.getRemotePath();
-            remoteParentPath = new File(remoteParentPath).getParent();
-            pathTextView.setText(mParentActivity.getString(R.string.app_name) + remoteParentPath);
+            String remoteParentPath = new File(upload.getRemotePath()).getParent();
+            pathTextView.setText(remoteParentPath);
 
             // file size
             TextView fileSizeTextView = (TextView) view.findViewById(R.id.upload_file_size);
@@ -316,7 +315,6 @@ public class ExpandableUploadListAdapter extends BaseExpandableListAdapter imple
                         );
                     }
                     uploadDateTextView.setVisibility(View.GONE);
-                    pathTextView.setVisibility(View.GONE);
                     fileSizeTextView.setVisibility(View.GONE);
                     progressBar.invalidate();
                     break;