Selaa lähdekoodia

Refactoring on UploadFileOperation instances building

Juan Carlos González Cabrero 9 vuotta sitten
vanhempi
commit
ce7fa469a4

+ 12 - 12
src/com/owncloud/android/files/services/FileUploader.java

@@ -481,9 +481,19 @@ public class FileUploader extends Service
             try {
                 for (int i = 0; i < files.length; i++) {
 
+                    OCUpload ocUpload = new OCUpload(files[i], account);
+                    ocUpload.setFileSize(files[i].getFileLength());
+                    ocUpload.setForceOverwrite(forceOverwrite);
+                    ocUpload.setCreateRemoteFolder(isCreateRemoteFolder);
+                    ocUpload.setCreatedBy(createdBy);
+                    ocUpload.setLocalAction(localAction);
+                    /*ocUpload.setUseWifiOnly(isUseWifiOnly);
+                    ocUpload.setWhileChargingOnly(isWhileChargingOnly);*/
+                    ocUpload.setUploadStatus(UploadStatus.UPLOAD_IN_PROGRESS);
+
                     newUpload = new UploadFileOperation(
                             account,
-                            files[i],
+                            ocUpload,
                             chunked,
                             forceOverwrite,
                             localAction,
@@ -498,17 +508,6 @@ public class FileUploader extends Service
 
                     newUpload.addRenameUploadListener(this);
 
-                    // Save upload in database
-                    OCUpload ocUpload = new OCUpload(files[i], account);
-                    ocUpload.setFileSize(files[i].getFileLength());
-                    ocUpload.setForceOverwrite(forceOverwrite);
-                    ocUpload.setCreateRemoteFolder(isCreateRemoteFolder);
-                    ocUpload.setCreatedBy(createdBy);
-                    ocUpload.setLocalAction(localAction);
-                    /*ocUpload.setUseWifiOnly(isUseWifiOnly);
-                    ocUpload.setWhileChargingOnly(isWhileChargingOnly);*/
-                    ocUpload.setUploadStatus(UploadStatus.UPLOAD_IN_PROGRESS);
-
                     Pair<String, String> putResult = mPendingUploads.putIfAbsent(
                             account.name,
                             files[i].getRemotePath(),
@@ -518,6 +517,7 @@ public class FileUploader extends Service
                         uploadKey = putResult.first;
                         requestedUploads.add(uploadKey);
 
+                        // Save upload in database
                         long id = mUploadsStorageManager.storeUpload(ocUpload);
                         newUpload.setOCUploadId(id);
                     }

+ 0 - 28
src/com/owncloud/android/operations/UploadFileOperation.java

@@ -137,34 +137,6 @@ public class UploadFileOperation extends SyncOperation {
 
     protected RequestEntity mEntity = null;
 
-    public UploadFileOperation(Account account,
-                               OCFile file,
-                               boolean chunked,
-                               boolean forceOverwrite,
-                               int localBehaviour,
-                               Context context
-    ) {
-        if (account == null)
-            throw new IllegalArgumentException("Illegal NULL account in UploadFileOperation " +
-                    "creation");
-        if (file == null)
-            throw new IllegalArgumentException("Illegal NULL file in UploadFileOperation creation");
-        if (file.getStoragePath() == null || file.getStoragePath().length() <= 0) {
-            throw new IllegalArgumentException(
-                    "Illegal file in UploadFileOperation; storage path invalid: "
-                            + file.getStoragePath());
-        }
-
-        mAccount = account;
-        mFile = file;
-        mRemotePath = file.getRemotePath();
-        mChunked = chunked;
-        mForceOverwrite = forceOverwrite;
-        mLocalBehaviour = localBehaviour;
-        mOriginalStoragePath = mFile.getStoragePath();
-        mContext = context;
-    }
-
     public UploadFileOperation(Account account,
                                OCUpload upload,
                                boolean chunked,