use of com.owncloud.android.datamodel.UploadsStorageManager in project android by owncloud.
the class SynchronizeFolderOperation method isBlockedForAutomatedSync.
/**
* Checks the last upload of a file and determines if automated synchronization needs to wait for
* user action or not.
*
* @param file ownCloud file to check.
* @return 'True' if the received file should not be automatically synced due to a previous
* upload error that requires an user action.
*/
private boolean isBlockedForAutomatedSync(OCFile file) {
UploadsStorageManager uploadsStorageManager = new UploadsStorageManager(mContext.getContentResolver());
OCUpload failedUpload = uploadsStorageManager.getLastUploadFor(file, mAccount.name);
if (failedUpload != null) {
switch(failedUpload.getLastResult()) {
case CREDENTIAL_ERROR:
case FOLDER_ERROR:
case FILE_NOT_FOUND:
case FILE_ERROR:
case PRIVILEGES_ERROR:
case CONFLICT_ERROR:
return true;
}
}
return false;
}
use of com.owncloud.android.datamodel.UploadsStorageManager in project android by owncloud.
the class TransferRequester method retryFailedUploads.
/**
* Retry a subset of all the stored failed uploads.
*
* @param context Caller {@link Context}
* @param account If not null, only failed uploads to this OC account will be retried; otherwise,
* uploads of all accounts will be retried.
* @param uploadResult If not null, only failed uploads with the result specified will be retried;
* otherwise, failed uploads due to any result will be retried.
* @param requestedFromWifiBackEvent true if the retry was requested because wifi connection was back,
* false otherwise
*/
public void retryFailedUploads(Context context, Account account, UploadResult uploadResult, boolean requestedFromWifiBackEvent) {
UploadsStorageManager uploadsStorageManager = new UploadsStorageManager(context.getContentResolver());
OCUpload[] failedUploads = uploadsStorageManager.getFailedUploads();
Account currentAccount = null;
boolean resultMatch, accountMatch;
for (OCUpload failedUpload : failedUploads) {
accountMatch = (account == null || account.name.equals(failedUpload.getAccountName()));
resultMatch = (uploadResult == null || uploadResult.equals(failedUpload.getLastResult()));
if (accountMatch && resultMatch) {
if (currentAccount == null || !currentAccount.name.equals(failedUpload.getAccountName())) {
currentAccount = failedUpload.getAccount(context);
}
retry(context, currentAccount, failedUpload, requestedFromWifiBackEvent);
}
}
}
use of com.owncloud.android.datamodel.UploadsStorageManager in project android by owncloud.
the class RetryUploadJobService method onStartJob.
@Override
public boolean onStartJob(JobParameters jobParameters) {
UploadsStorageManager uploadsStorageManager = new UploadsStorageManager(getContentResolver());
String fileRemotePath = jobParameters.getExtras().getString(Extras.EXTRA_REMOTE_PATH);
String accountName = jobParameters.getExtras().getString(Extras.EXTRA_ACCOUNT_NAME);
Timber.d("Retrying upload of %1s in %2s", fileRemotePath, accountName);
// Get upload to be retried
OCUpload ocUpload = uploadsStorageManager.getLastUploadFor(new OCFile(fileRemotePath), accountName);
if (ocUpload != null) {
// Retry the upload
TransferRequester requester = new TransferRequester();
requester.retry(this, ocUpload, true);
} else {
// easy if the user deletes the upload in uploads view before recovering network
Timber.w("No upload found in database for %1s in %2s", fileRemotePath, accountName);
}
// done here, real job was delegated to another castle
jobFinished(jobParameters, false);
// TODO or false? what is the real effect, Google!?!?!?!?
return true;
}
use of com.owncloud.android.datamodel.UploadsStorageManager in project android by owncloud.
the class UploadListFragment method onClick.
@Override
public void onClick(OptionsInUploadList option) {
UploadsStorageManager storageManager;
switch(option) {
case RETRY_FAILED:
TransferRequester requester = new TransferRequester();
requester.retryFailedUploads(requireContext(), null, null, false);
break;
case CLEAR_FAILED:
storageManager = new UploadsStorageManager(requireActivity().getContentResolver());
storageManager.clearFailedButNotDelayedForWifiUploads();
break;
case CLEAR_SUCCESSFUL:
storageManager = new UploadsStorageManager(requireActivity().getContentResolver());
storageManager.clearSuccessfulUploads();
break;
}
updateUploads();
}
use of com.owncloud.android.datamodel.UploadsStorageManager in project android by nextcloud.
the class AbstractIT method uploadOCUpload.
public void uploadOCUpload(OCUpload ocUpload) {
ConnectivityService connectivityServiceMock = new ConnectivityService() {
@Override
public boolean isInternetWalled() {
return false;
}
@Override
public Connectivity getConnectivity() {
return Connectivity.CONNECTED_WIFI;
}
};
PowerManagementService powerManagementServiceMock = new PowerManagementService() {
@NonNull
@Override
public BatteryStatus getBattery() {
return new BatteryStatus();
}
@Override
public boolean isPowerSavingEnabled() {
return false;
}
@Override
public boolean isPowerSavingExclusionAvailable() {
return false;
}
};
UserAccountManager accountManager = UserAccountManagerImpl.fromContext(targetContext);
UploadsStorageManager uploadsStorageManager = new UploadsStorageManager(accountManager, targetContext.getContentResolver());
UploadFileOperation newUpload = new UploadFileOperation(uploadsStorageManager, connectivityServiceMock, powerManagementServiceMock, user, null, ocUpload, NameCollisionPolicy.DEFAULT, FileUploader.LOCAL_BEHAVIOUR_COPY, targetContext, false, false, getStorageManager());
newUpload.addRenameUploadListener(() -> {
// dummy
});
newUpload.setRemoteFolderToBeCreated();
RemoteOperationResult result = newUpload.execute(client);
assertTrue(result.getLogMessage(), result.isSuccess());
}
Aggregations