|
@@ -1,22 +1,22 @@
|
|
|
/**
|
|
|
- * ownCloud Android client application
|
|
|
+ * ownCloud Android client application
|
|
|
*
|
|
|
- * @author LukeOwncloud
|
|
|
- * @author David A. Velasco
|
|
|
- * @author masensio
|
|
|
- * Copyright (C) 2016 ownCloud Inc.
|
|
|
+ * @author LukeOwncloud
|
|
|
+ * @author David A. Velasco
|
|
|
+ * @author masensio
|
|
|
+ * Copyright (C) 2016 ownCloud Inc.
|
|
|
*
|
|
|
- * This program is free software: you can redistribute it and/or modify
|
|
|
- * it under the terms of the GNU General Public License version 2,
|
|
|
- * as published by the Free Software Foundation.
|
|
|
+ * This program is free software: you can redistribute it and/or modify
|
|
|
+ * it under the terms of the GNU General Public License version 2,
|
|
|
+ * as published by the Free Software Foundation.
|
|
|
*
|
|
|
- * This program is distributed in the hope that it will be useful,
|
|
|
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
- * GNU General Public License for more details.
|
|
|
+ * This program is distributed in the hope that it will be useful,
|
|
|
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
+ * GNU General Public License for more details.
|
|
|
*
|
|
|
- * You should have received a copy of the GNU General Public License
|
|
|
- * along with this program. If not, see <http://www.gnu.org/licenses/>.
|
|
|
+ * You should have received a copy of the GNU General Public License
|
|
|
+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
|
|
|
*/
|
|
|
package com.owncloud.android.datamodel;
|
|
|
|
|
@@ -26,12 +26,8 @@ import android.content.ContentValues;
|
|
|
import android.content.Context;
|
|
|
import android.database.Cursor;
|
|
|
import android.net.Uri;
|
|
|
-import android.os.Build;
|
|
|
-import android.support.annotation.RequiresApi;
|
|
|
|
|
|
-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;
|
|
@@ -39,14 +35,9 @@ import com.owncloud.android.files.services.FileUploader;
|
|
|
import com.owncloud.android.lib.common.operations.RemoteOperationResult;
|
|
|
import com.owncloud.android.lib.common.utils.Log_OC;
|
|
|
import com.owncloud.android.operations.UploadFileOperation;
|
|
|
-import com.owncloud.android.services.AutoUploadJob;
|
|
|
|
|
|
-import java.util.ArrayList;
|
|
|
import java.util.Calendar;
|
|
|
-import java.util.Collections;
|
|
|
-import java.util.List;
|
|
|
import java.util.Observable;
|
|
|
-import java.util.Set;
|
|
|
|
|
|
/**
|
|
|
* Database helper for storing list of files to be uploaded, including status
|
|
@@ -130,6 +121,8 @@ public class UploadsStorageManager extends Observable {
|
|
|
cv.put(ProviderTableMeta.UPLOADS_IS_CREATE_REMOTE_FOLDER, ocUpload.isCreateRemoteFolder() ? 1 : 0);
|
|
|
cv.put(ProviderTableMeta.UPLOADS_LAST_RESULT, ocUpload.getLastResult().getValue());
|
|
|
cv.put(ProviderTableMeta.UPLOADS_CREATED_BY, ocUpload.getCreadtedBy());
|
|
|
+ cv.put(ProviderTableMeta.UPLOADS_IS_WHILE_CHARGING_ONLY, ocUpload.isWhileChargingOnly() ? 1 : 0);
|
|
|
+ cv.put(ProviderTableMeta.UPLOADS_IS_WIFI_ONLY, ocUpload.isUseWifiOnly() ? 1 : 0);
|
|
|
|
|
|
Uri result = getDB().insert(ProviderTableMeta.CONTENT_URI_UPLOADS, cv);
|
|
|
|
|
@@ -163,9 +156,9 @@ public class UploadsStorageManager extends Observable {
|
|
|
cv.put(ProviderTableMeta.UPLOADS_UPLOAD_END_TIMESTAMP, ocUpload.getUploadEndTimestamp());
|
|
|
|
|
|
int result = getDB().update(ProviderTableMeta.CONTENT_URI_UPLOADS,
|
|
|
- cv,
|
|
|
- ProviderTableMeta._ID + "=?",
|
|
|
- new String[]{String.valueOf(ocUpload.getUploadId())}
|
|
|
+ cv,
|
|
|
+ ProviderTableMeta._ID + "=?",
|
|
|
+ new String[]{String.valueOf(ocUpload.getUploadId())}
|
|
|
);
|
|
|
|
|
|
Log_OC.d(TAG, "updateUpload returns with: " + result + " for file: " + ocUpload.getLocalPath());
|
|
@@ -188,15 +181,15 @@ public class UploadsStorageManager extends Observable {
|
|
|
|
|
|
String path = c.getString(c.getColumnIndex(ProviderTableMeta.UPLOADS_LOCAL_PATH));
|
|
|
Log_OC.v(
|
|
|
- TAG,
|
|
|
- "Updating " + path + " with status:" + status + " and result:"
|
|
|
- + (result == null ? "null" : result.toString()) + " (old:"
|
|
|
- + upload.toFormattedString() + ")");
|
|
|
+ TAG,
|
|
|
+ "Updating " + path + " with status:" + status + " and result:"
|
|
|
+ + (result == null ? "null" : result.toString()) + " (old:"
|
|
|
+ + upload.toFormattedString() + ")");
|
|
|
|
|
|
upload.setUploadStatus(status);
|
|
|
upload.setLastResult(result);
|
|
|
upload.setRemotePath(remotePath);
|
|
|
- if(localPath != null) {
|
|
|
+ if (localPath != null) {
|
|
|
upload.setLocalPath(localPath);
|
|
|
}
|
|
|
if (status == UploadStatus.UPLOAD_SUCCEEDED) {
|
|
@@ -221,7 +214,7 @@ public class UploadsStorageManager extends Observable {
|
|
|
* @param localPath path of the file to upload in the device storage
|
|
|
* @return 1 if file status was updated, else 0.
|
|
|
*/
|
|
|
- public int updateUploadStatus(long id, UploadStatus status, UploadResult result, String remotePath,
|
|
|
+ private int updateUploadStatus(long id, UploadStatus status, UploadResult result, String remotePath,
|
|
|
String localPath) {
|
|
|
//Log_OC.v(TAG, "Updating "+filepath+" with uploadStatus="+status +" and result="+result);
|
|
|
|
|
@@ -236,7 +229,7 @@ public class UploadsStorageManager extends Observable {
|
|
|
|
|
|
if (c.getCount() != 1) {
|
|
|
Log_OC.e(TAG, c.getCount() + " items for id=" + id
|
|
|
- + " available in UploadDb. Expected 1. Failed to update upload db.");
|
|
|
+ + " available in UploadDb. Expected 1. Failed to update upload db.");
|
|
|
} else {
|
|
|
returnValue = updateUploadInternal(c, status, result, remotePath, localPath);
|
|
|
}
|
|
@@ -266,7 +259,7 @@ public class UploadsStorageManager extends Observable {
|
|
|
public int removeUpload(OCUpload upload) {
|
|
|
int result = getDB().delete(
|
|
|
ProviderTableMeta.CONTENT_URI_UPLOADS,
|
|
|
- ProviderTableMeta._ID + "=?" ,
|
|
|
+ ProviderTableMeta._ID + "=?",
|
|
|
new String[]{Long.toString(upload.getUploadId())}
|
|
|
);
|
|
|
Log_OC.d(TAG, "delete returns " + result + " for upload " + upload);
|
|
@@ -287,7 +280,7 @@ public class UploadsStorageManager extends Observable {
|
|
|
public int removeUpload(String accountName, String remotePath) {
|
|
|
int result = getDB().delete(
|
|
|
ProviderTableMeta.CONTENT_URI_UPLOADS,
|
|
|
- ProviderTableMeta.UPLOADS_ACCOUNT_NAME + "=? AND " + ProviderTableMeta.UPLOADS_REMOTE_PATH + "=?" ,
|
|
|
+ ProviderTableMeta.UPLOADS_ACCOUNT_NAME + "=? AND " + ProviderTableMeta.UPLOADS_REMOTE_PATH + "=?",
|
|
|
new String[]{accountName, remotePath}
|
|
|
);
|
|
|
Log_OC.d(TAG, "delete returns " + result + " for file " + remotePath + " in " + accountName);
|
|
@@ -374,68 +367,21 @@ public class UploadsStorageManager extends Observable {
|
|
|
return upload;
|
|
|
}
|
|
|
|
|
|
- /**
|
|
|
- * Get all uploads which are currently being uploaded or waiting in the queue to be uploaded.
|
|
|
- */
|
|
|
- public OCUpload[] getCurrentAndPendingUploads() {
|
|
|
+ public OCUpload[] getCurrentAndPendingUploadsForCurrentAccount() {
|
|
|
+ Account account = AccountUtils.getCurrentOwnCloudAccount(mContext);
|
|
|
|
|
|
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.DELAYED_FOR_CHARGING.getValue(),
|
|
|
- null
|
|
|
+ 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}
|
|
|
);
|
|
|
|
|
|
- // add pending Jobs
|
|
|
- if (Build.VERSION.SDK_INT < Build.VERSION_CODES.LOLLIPOP) {
|
|
|
- return uploads;
|
|
|
- } else {
|
|
|
- List<OCUpload> result = getPendingJobs();
|
|
|
- Collections.addAll(result, uploads);
|
|
|
- return result.toArray(uploads);
|
|
|
- }
|
|
|
- }
|
|
|
-
|
|
|
- @RequiresApi(Build.VERSION_CODES.LOLLIPOP)
|
|
|
- private List<OCUpload> getPendingJobs() {
|
|
|
- Set<JobRequest> jobRequests = JobManager.create(mContext).getAllJobRequestsForTag(AutoUploadJob.TAG);
|
|
|
-
|
|
|
- ArrayList<OCUpload> list = new ArrayList<>();
|
|
|
-
|
|
|
- for (JobRequest ji : jobRequests) {
|
|
|
- PersistableBundleCompat extras = ji.getExtras();
|
|
|
- OCUpload upload = new OCUpload(extras.getString("filePath", ""),
|
|
|
- extras.getString("remotePath", ""),
|
|
|
- extras.getString("account", ""));
|
|
|
-
|
|
|
- list.add(upload);
|
|
|
- }
|
|
|
-
|
|
|
- return list;
|
|
|
- }
|
|
|
+ return uploads;
|
|
|
|
|
|
- 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());
|
|
|
- }
|
|
|
- }
|
|
|
- }
|
|
|
-
|
|
|
- @RequiresApi(Build.VERSION_CODES.LOLLIPOP)
|
|
|
- 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;
|
|
|
- }
|
|
|
- }
|
|
|
}
|
|
|
|
|
|
/**
|
|
@@ -447,6 +393,13 @@ public class UploadsStorageManager extends Observable {
|
|
|
ProviderTableMeta.UPLOADS_STATUS + "==" + UploadStatus.UPLOAD_FAILED.value, null);
|
|
|
}
|
|
|
|
|
|
+ public OCUpload[] getFinishedUploadsForCurrentAccount() {
|
|
|
+ Account account = AccountUtils.getCurrentOwnCloudAccount(mContext);
|
|
|
+
|
|
|
+ return getUploads(ProviderTableMeta.UPLOADS_STATUS + "==" + UploadStatus.UPLOAD_SUCCEEDED.value + AND +
|
|
|
+ ProviderTableMeta.UPLOADS_ACCOUNT_NAME + "== ?", new String[]{account.name});
|
|
|
+ }
|
|
|
+
|
|
|
/**
|
|
|
* Get all uploads which where successfully completed.
|
|
|
*/
|
|
@@ -455,16 +408,33 @@ public class UploadsStorageManager extends Observable {
|
|
|
return getUploads(ProviderTableMeta.UPLOADS_STATUS + "==" + UploadStatus.UPLOAD_SUCCEEDED.value, null);
|
|
|
}
|
|
|
|
|
|
+ public OCUpload[] getFailedButNotDelayedUploadsForCurrentAccount() {
|
|
|
+ Account account = AccountUtils.getCurrentOwnCloudAccount(mContext);
|
|
|
+
|
|
|
+ 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}
|
|
|
+ );
|
|
|
+ }
|
|
|
+
|
|
|
/**
|
|
|
- * Get all failed uploads, except for those that were not performed due to lack of Wifi connection
|
|
|
- * @return Array of failed uploads, except for those that were not performed due to lack of Wifi connection.
|
|
|
+ * Get all failed uploads, except for those that were not performed due to lack of Wifi connection.
|
|
|
+ *
|
|
|
+ * @return Array of failed uploads, except for those that were not performed due to lack of Wifi connection.
|
|
|
*/
|
|
|
public OCUpload[] getFailedButNotDelayedUploads() {
|
|
|
|
|
|
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.DELAYED_FOR_CHARGING.getValue(),
|
|
|
- null
|
|
|
+ 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
|
|
|
);
|
|
|
}
|
|
|
|
|
@@ -473,13 +443,22 @@ public class UploadsStorageManager extends Observable {
|
|
|
}
|
|
|
|
|
|
public long clearFailedButNotDelayedUploads() {
|
|
|
+ Account account = AccountUtils.getCurrentOwnCloudAccount(mContext);
|
|
|
+
|
|
|
long result = getDB().delete(
|
|
|
- ProviderTableMeta.CONTENT_URI_UPLOADS,
|
|
|
- ProviderTableMeta.UPLOADS_STATUS + "==" + UploadStatus.UPLOAD_FAILED.value + AND +
|
|
|
- ProviderTableMeta.UPLOADS_LAST_RESULT + "<>" + UploadResult.DELAYED_FOR_WIFI.getValue() + AND +
|
|
|
- ProviderTableMeta.UPLOADS_LAST_RESULT + "<>" + UploadResult.DELAYED_FOR_CHARGING.getValue(),
|
|
|
- null
|
|
|
+ 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() +
|
|
|
+ AND +
|
|
|
+ ProviderTableMeta.UPLOADS_ACCOUNT_NAME + "== ?",
|
|
|
+ new String[]{account.name}
|
|
|
);
|
|
|
+
|
|
|
Log_OC.d(TAG, "delete all failed uploads but those delayed for Wifi");
|
|
|
if (result > 0) {
|
|
|
notifyObserversNow();
|
|
@@ -488,11 +467,14 @@ public class UploadsStorageManager extends Observable {
|
|
|
}
|
|
|
|
|
|
public long clearSuccessfulUploads() {
|
|
|
+ Account account = AccountUtils.getCurrentOwnCloudAccount(mContext);
|
|
|
|
|
|
long result = getDB().delete(
|
|
|
ProviderTableMeta.CONTENT_URI_UPLOADS,
|
|
|
- ProviderTableMeta.UPLOADS_STATUS + "=="+ UploadStatus.UPLOAD_SUCCEEDED.value, null
|
|
|
+ ProviderTableMeta.UPLOADS_STATUS + "==" + UploadStatus.UPLOAD_SUCCEEDED.value + AND +
|
|
|
+ ProviderTableMeta.UPLOADS_ACCOUNT_NAME + "== ?", new String[]{account.name}
|
|
|
);
|
|
|
+
|
|
|
Log_OC.d(TAG, "delete all successful uploads");
|
|
|
if (result > 0) {
|
|
|
notifyObserversNow();
|
|
@@ -501,21 +483,31 @@ public class UploadsStorageManager extends Observable {
|
|
|
}
|
|
|
|
|
|
public long clearAllFinishedButNotDelayedUploads() {
|
|
|
+ Account account = AccountUtils.getCurrentOwnCloudAccount(mContext);
|
|
|
|
|
|
- String[] whereArgs = new String[2];
|
|
|
+ String[] whereArgs = new String[3];
|
|
|
whereArgs[0] = String.valueOf(UploadStatus.UPLOAD_SUCCEEDED.value);
|
|
|
whereArgs[1] = String.valueOf(UploadStatus.UPLOAD_FAILED.value);
|
|
|
+ whereArgs[2] = account.name;
|
|
|
long result = getDB().delete(
|
|
|
ProviderTableMeta.CONTENT_URI_UPLOADS,
|
|
|
- ProviderTableMeta.UPLOADS_STATUS + "=? OR " + ProviderTableMeta.UPLOADS_STATUS + "=? AND " +
|
|
|
- ProviderTableMeta.UPLOADS_LAST_RESULT + "<>" + UploadResult.DELAYED_FOR_WIFI.getValue() + AND +
|
|
|
- ProviderTableMeta.UPLOADS_LAST_RESULT + "<>" + UploadResult.DELAYED_FOR_CHARGING.getValue(),
|
|
|
+ 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() +
|
|
|
+ AND +
|
|
|
+ ProviderTableMeta.UPLOADS_ACCOUNT_NAME + "== ?",
|
|
|
whereArgs
|
|
|
);
|
|
|
+
|
|
|
Log_OC.d(TAG, "delete all finished uploads");
|
|
|
if (result > 0) {
|
|
|
notifyObserversNow();
|
|
|
}
|
|
|
+
|
|
|
return result;
|
|
|
}
|
|
|
|
|
@@ -528,28 +520,28 @@ public class UploadsStorageManager extends Observable {
|
|
|
|
|
|
if (uploadResult.isCancelled()) {
|
|
|
removeUpload(
|
|
|
- upload.getAccount().name,
|
|
|
- upload.getRemotePath()
|
|
|
+ upload.getAccount().name,
|
|
|
+ upload.getRemotePath()
|
|
|
);
|
|
|
} else {
|
|
|
String localPath = (FileUploader.LOCAL_BEHAVIOUR_MOVE == upload.getLocalBehaviour())
|
|
|
- ? upload.getStoragePath() : null;
|
|
|
+ ? upload.getStoragePath() : null;
|
|
|
|
|
|
if (uploadResult.isSuccess()) {
|
|
|
updateUploadStatus(
|
|
|
- upload.getOCUploadId(),
|
|
|
- UploadStatus.UPLOAD_SUCCEEDED,
|
|
|
- UploadResult.UPLOADED,
|
|
|
- upload.getRemotePath(),
|
|
|
- localPath
|
|
|
+ upload.getOCUploadId(),
|
|
|
+ UploadStatus.UPLOAD_SUCCEEDED,
|
|
|
+ UploadResult.UPLOADED,
|
|
|
+ upload.getRemotePath(),
|
|
|
+ localPath
|
|
|
);
|
|
|
} else {
|
|
|
updateUploadStatus(
|
|
|
- upload.getOCUploadId(),
|
|
|
- UploadStatus.UPLOAD_FAILED,
|
|
|
- UploadResult.fromOperationResult(uploadResult),
|
|
|
- upload.getRemotePath(),
|
|
|
- localPath
|
|
|
+ upload.getOCUploadId(),
|
|
|
+ UploadStatus.UPLOAD_FAILED,
|
|
|
+ UploadResult.fromOperationResult(uploadResult),
|
|
|
+ upload.getRemotePath(),
|
|
|
+ localPath
|
|
|
);
|
|
|
}
|
|
|
}
|
|
@@ -560,14 +552,14 @@ public class UploadsStorageManager extends Observable {
|
|
|
*/
|
|
|
public void updateDatabaseUploadStart(UploadFileOperation upload) {
|
|
|
String localPath = (FileUploader.LOCAL_BEHAVIOUR_MOVE == upload.getLocalBehaviour())
|
|
|
- ? upload.getStoragePath() : null;
|
|
|
+ ? upload.getStoragePath() : null;
|
|
|
|
|
|
updateUploadStatus(
|
|
|
- upload.getOCUploadId(),
|
|
|
- UploadStatus.UPLOAD_IN_PROGRESS,
|
|
|
- UploadResult.UNKNOWN,
|
|
|
- upload.getRemotePath(),
|
|
|
- localPath
|
|
|
+ upload.getOCUploadId(),
|
|
|
+ UploadStatus.UPLOAD_IN_PROGRESS,
|
|
|
+ UploadResult.UNKNOWN,
|
|
|
+ upload.getRemotePath(),
|
|
|
+ localPath
|
|
|
);
|
|
|
}
|
|
|
|
|
@@ -576,7 +568,7 @@ public class UploadsStorageManager extends Observable {
|
|
|
* Changes the status of any in progress upload from UploadStatus.UPLOAD_IN_PROGRESS
|
|
|
* to UploadStatus.UPLOAD_FAILED
|
|
|
*
|
|
|
- * @return Number of uploads which status was changed.
|
|
|
+ * @return Number of uploads which status was changed.
|
|
|
*/
|
|
|
public int failInProgressUploads(UploadResult fail) {
|
|
|
Log_OC.v(TAG, "Updating state of any killed upload");
|
|
@@ -584,16 +576,16 @@ public class UploadsStorageManager extends Observable {
|
|
|
ContentValues cv = new ContentValues();
|
|
|
cv.put(ProviderTableMeta.UPLOADS_STATUS, UploadStatus.UPLOAD_FAILED.getValue());
|
|
|
cv.put(
|
|
|
- ProviderTableMeta.UPLOADS_LAST_RESULT,
|
|
|
- fail != null ? fail.getValue() : UploadResult.UNKNOWN.getValue()
|
|
|
+ ProviderTableMeta.UPLOADS_LAST_RESULT,
|
|
|
+ fail != null ? fail.getValue() : UploadResult.UNKNOWN.getValue()
|
|
|
);
|
|
|
cv.put(ProviderTableMeta.UPLOADS_UPLOAD_END_TIMESTAMP, Calendar.getInstance().getTimeInMillis());
|
|
|
|
|
|
int result = getDB().update(
|
|
|
- ProviderTableMeta.CONTENT_URI_UPLOADS,
|
|
|
- cv,
|
|
|
- ProviderTableMeta.UPLOADS_STATUS + "=?",
|
|
|
- new String[]{String.valueOf(UploadStatus.UPLOAD_IN_PROGRESS.getValue())}
|
|
|
+ ProviderTableMeta.CONTENT_URI_UPLOADS,
|
|
|
+ cv,
|
|
|
+ ProviderTableMeta.UPLOADS_STATUS + "=?",
|
|
|
+ new String[]{String.valueOf(UploadStatus.UPLOAD_IN_PROGRESS.getValue())}
|
|
|
);
|
|
|
|
|
|
if (result == 0) {
|
|
@@ -602,15 +594,7 @@ public class UploadsStorageManager extends Observable {
|
|
|
Log_OC.w(TAG, Integer.toString(result) + " uploads where abruptly interrupted");
|
|
|
notifyObserversNow();
|
|
|
}
|
|
|
- return result;
|
|
|
- }
|
|
|
|
|
|
- public int removeAccountUploads(Account account) {
|
|
|
- Log_OC.v(TAG, "Delete all uploads for account " + account.name);
|
|
|
- return getDB().delete(
|
|
|
- ProviderTableMeta.CONTENT_URI_UPLOADS,
|
|
|
- ProviderTableMeta.UPLOADS_ACCOUNT_NAME + "=?",
|
|
|
- new String[]{account.name});
|
|
|
+ return result;
|
|
|
}
|
|
|
-
|
|
|
}
|