ソースを参照

More work

Signed-off-by: Mario Danic <mario@lovelyhq.com>
Mario Danic 7 年 前
コミット
05fe12b92d

+ 5 - 28
src/main/java/com/owncloud/android/datamodel/UploadsStorageManager.java

@@ -27,22 +27,17 @@ import android.content.Context;
 import android.database.Cursor;
 import android.net.Uri;
 
-import com.evernote.android.job.JobManager;
-import com.evernote.android.job.JobRequest;
-import com.evernote.android.job.util.support.PersistableBundleCompat;
 import com.owncloud.android.authentication.AccountUtils;
 import com.owncloud.android.db.OCUpload;
 import com.owncloud.android.db.ProviderMeta.ProviderTableMeta;
 import com.owncloud.android.db.UploadResult;
 import com.owncloud.android.files.services.FileUploader;
-import com.owncloud.android.jobs.AutoUploadJob;
 import com.owncloud.android.lib.common.operations.RemoteOperationResult;
 import com.owncloud.android.lib.common.utils.Log_OC;
 import com.owncloud.android.operations.UploadFileOperation;
 
 import java.util.Calendar;
 import java.util.Observable;
-import java.util.Set;
 
 /**
  * Database helper for storing list of files to be uploaded, including status
@@ -378,6 +373,7 @@ public class UploadsStorageManager extends Observable {
         OCUpload[] uploads = getUploads(
                 ProviderTableMeta.UPLOADS_STATUS + "==" + UploadStatus.UPLOAD_IN_PROGRESS.value + " OR " +
                         ProviderTableMeta.UPLOADS_LAST_RESULT + "==" + UploadResult.DELAYED_FOR_WIFI.getValue() + " OR " +
+                        ProviderTableMeta.UPLOADS_LAST_RESULT + "==" + UploadResult.LOCK_FAILED.getValue() + " OR " +
                         ProviderTableMeta.UPLOADS_LAST_RESULT + "==" + UploadResult.DELAYED_FOR_CHARGING.getValue() + " AND " +
                         ProviderTableMeta.UPLOADS_ACCOUNT_NAME + "== ?",
                 new String[]{account.name}
@@ -387,29 +383,6 @@ public class UploadsStorageManager extends Observable {
 
     }
 
-    public void cancelPendingAutoUploadJobsForAccount(Account account) {
-        JobManager jobManager = JobManager.create(mContext);
-        for (JobRequest ji : jobManager.getAllJobRequestsForTag(AutoUploadJob.TAG)) {
-            if (ji.getExtras().getString(AutoUploadJob.ACCOUNT, "").equalsIgnoreCase(account.name)) {
-                jobManager.cancel(ji.getJobId());
-            }
-        }
-    }
-
-    public void cancelPendingJob(String accountName, String remotePath) {
-        JobManager jobManager = JobManager.create(mContext);
-        Set<JobRequest> jobRequests = jobManager.getAllJobRequests();
-
-        for (JobRequest ji : jobRequests) {
-            PersistableBundleCompat extras = ji.getExtras();
-            if (remotePath.equalsIgnoreCase(extras.getString("remotePath", "")) &&
-                    accountName.equalsIgnoreCase(extras.getString("account", ""))) {
-                jobManager.cancel(ji.getJobId());
-                break;
-            }
-        }
-    }
-
     /**
      * Get all failed uploads.
      */
@@ -439,6 +412,7 @@ public class UploadsStorageManager extends Observable {
 
         return getUploads(ProviderTableMeta.UPLOADS_STATUS + "==" + UploadStatus.UPLOAD_FAILED.value + AND +
                         ProviderTableMeta.UPLOADS_LAST_RESULT + "<>" + UploadResult.DELAYED_FOR_WIFI.getValue() + AND +
+                        ProviderTableMeta.UPLOADS_LAST_RESULT + "<>" + UploadResult.LOCK_FAILED.getValue() + AND +
                         ProviderTableMeta.UPLOADS_LAST_RESULT + "<>" + UploadResult.DELAYED_FOR_CHARGING.getValue() + AND +
                         ProviderTableMeta.UPLOADS_ACCOUNT_NAME + "== ?",
                 new String[]{account.name}
@@ -452,6 +426,7 @@ public class UploadsStorageManager extends Observable {
     public OCUpload[] getFailedButNotDelayedUploads() {
 
         return getUploads(ProviderTableMeta.UPLOADS_STATUS + "==" + UploadStatus.UPLOAD_FAILED.value + AND +
+                        ProviderTableMeta.UPLOADS_LAST_RESULT + "<>" + UploadResult.LOCK_FAILED.getValue() + AND +
                         ProviderTableMeta.UPLOADS_LAST_RESULT + "<>" + UploadResult.DELAYED_FOR_WIFI.getValue() + AND +
                         ProviderTableMeta.UPLOADS_LAST_RESULT + "<>" + UploadResult.DELAYED_FOR_CHARGING.getValue(),
                 null
@@ -466,6 +441,7 @@ public class UploadsStorageManager extends Observable {
         long result = getDB().delete(
                 ProviderTableMeta.CONTENT_URI_UPLOADS,
                 ProviderTableMeta.UPLOADS_STATUS + "==" + UploadStatus.UPLOAD_FAILED.value + AND +
+                        ProviderTableMeta.UPLOADS_LAST_RESULT + "<>" + UploadResult.LOCK_FAILED.getValue() + AND +
                         ProviderTableMeta.UPLOADS_LAST_RESULT + "<>" + UploadResult.DELAYED_FOR_WIFI.getValue() + AND +
                         ProviderTableMeta.UPLOADS_LAST_RESULT + "<>" + UploadResult.DELAYED_FOR_CHARGING.getValue(),
                 null
@@ -498,6 +474,7 @@ public class UploadsStorageManager extends Observable {
         long result = getDB().delete(
                 ProviderTableMeta.CONTENT_URI_UPLOADS,
                 ProviderTableMeta.UPLOADS_STATUS + "=? OR " + ProviderTableMeta.UPLOADS_STATUS + "=? AND " +
+                        ProviderTableMeta.UPLOADS_LAST_RESULT + "<>" + UploadResult.LOCK_FAILED.getValue() + AND +
                         ProviderTableMeta.UPLOADS_LAST_RESULT + "<>" + UploadResult.DELAYED_FOR_WIFI.getValue() + AND +
                         ProviderTableMeta.UPLOADS_LAST_RESULT + "<>" + UploadResult.DELAYED_FOR_CHARGING.getValue(),
                 whereArgs

+ 0 - 3
src/main/java/com/owncloud/android/files/services/FileUploader.java

@@ -784,9 +784,6 @@ public class FileUploader extends Service
                 } else {
                     mUploadsStorageManager.removeUpload(accountName, remotePath);
                 }
-            } else {
-                // try to cancel job in jobScheduler
-                mUploadsStorageManager.cancelPendingJob(accountName, remotePath);
             }
         }
 

+ 0 - 6
src/main/java/com/owncloud/android/ui/activity/UserInfoActivity.java

@@ -63,7 +63,6 @@ import com.owncloud.android.authentication.AuthenticatorActivity;
 import com.owncloud.android.datamodel.ArbitraryDataProvider;
 import com.owncloud.android.datamodel.PushConfigurationState;
 import com.owncloud.android.datamodel.SyncedFolderProvider;
-import com.owncloud.android.datamodel.UploadsStorageManager;
 import com.owncloud.android.lib.common.UserInfo;
 import com.owncloud.android.lib.common.operations.RemoteOperation;
 import com.owncloud.android.lib.common.operations.RemoteOperationResult;
@@ -410,11 +409,6 @@ public class UserInfoActivity extends FileActivity {
                                             contentResolver);
                                     syncedFolderProvider.deleteSyncFoldersForAccount(account);
 
-                                    UploadsStorageManager uploadsStorageManager = new UploadsStorageManager(
-                                            contentResolver, getActivity());
-                                    uploadsStorageManager.cancelPendingAutoUploadJobsForAccount(account);
-                                    uploadsStorageManager.removeAccountUploads(account);
-
                                     // disable daily backup
                                     ArbitraryDataProvider arbitraryDataProvider = new ArbitraryDataProvider(
                                             contentResolver);

+ 1 - 2
src/main/java/com/owncloud/android/utils/FilesSyncHelper.java

@@ -195,7 +195,6 @@ public class FilesSyncHelper {
 
         for (OCUpload failedUpload : failedUploads) {
             accountExists = false;
-            fileExists = new File(failedUpload.getLocalPath()).exists();
 
             // check if accounts still exists
             for (Account account : AccountUtils.getAccounts(context)) {
@@ -205,7 +204,7 @@ public class FilesSyncHelper {
                 }
             }
 
-            if (!accountExists || !fileExists) {
+            if (!accountExists) {
                 uploadsStorageManager.removeUpload(failedUpload);
             }
         }