mirror of
https://github.com/nextcloud/android.git
synced 2024-11-23 21:55:48 +03:00
Checking of local file when an upload retry is requested
This commit is contained in:
parent
d2940f6214
commit
a506014d58
5 changed files with 28 additions and 3 deletions
|
@ -1 +1 @@
|
|||
Subproject commit b0ac6b3fc94aa52a43927fae7b548e9123acf1bb
|
||||
Subproject commit 6ff6f75ee20e1b28f84a3ca5213dccb5907a2bed
|
|
@ -127,6 +127,7 @@
|
|||
<string name="uploads_view_upload_status_failed_credentials_error">Credentials error</string>
|
||||
<string name="uploads_view_upload_status_failed_folder_error">Folder error</string>
|
||||
<string name="uploads_view_upload_status_failed_file_error">File error</string>
|
||||
<string name="uploads_view_upload_status_failed_localfile_error">Local file not found</string>
|
||||
<string name="uploads_view_upload_status_failed_permission_error">Permission error</string>
|
||||
<string name="uploads_view_upload_status_failed">Upload failed</string>
|
||||
<string name="uploads_view_later_reason_waiting_for">Waiting for </string>
|
||||
|
@ -440,5 +441,6 @@
|
|||
<string name="manage_space_error">Some files could not be deleted.</string>
|
||||
|
||||
<string name="permission_storage_access">Additional permissions required to upload & download files.</string>
|
||||
<string name="local_file_not_found_toast">The file was not found locally</string>
|
||||
|
||||
</resources>
|
||||
|
|
|
@ -33,7 +33,8 @@ public enum UploadResult {
|
|||
FILE_ERROR(5),
|
||||
PRIVILEDGES_ERROR(6),
|
||||
CANCELLED(7),
|
||||
UNKNOWN(8);
|
||||
FILE_NOT_FOUND(8),
|
||||
UNKNOWN(9);
|
||||
|
||||
private final int value;
|
||||
|
||||
|
@ -63,6 +64,8 @@ public enum UploadResult {
|
|||
case 7:
|
||||
return CANCELLED;
|
||||
case 8:
|
||||
return FILE_NOT_FOUND;
|
||||
case 9:
|
||||
return UNKNOWN;
|
||||
}
|
||||
return null;
|
||||
|
@ -82,6 +85,8 @@ public enum UploadResult {
|
|||
return CREDENTIAL_ERROR;
|
||||
case FILE_NOT_FOUND:
|
||||
return FOLDER_ERROR;
|
||||
case LOCAL_FILE_NOT_FOUND:
|
||||
return FILE_NOT_FOUND;
|
||||
case CONFLICT:
|
||||
return CONFLICT_ERROR;
|
||||
case LOCAL_STORAGE_NOT_COPIED:
|
||||
|
|
|
@ -332,6 +332,13 @@ public class UploadFileOperation extends SyncOperation {
|
|||
mUploadStarted.set(true);
|
||||
RemoteOperationResult result = null;
|
||||
File temporalFile = null, originalFile = new File(mOriginalStoragePath), expectedFile = null;
|
||||
|
||||
// check if the file continues existing before schedule the operation
|
||||
if (!originalFile.exists()) {
|
||||
Log_OC.d(TAG, mOriginalStoragePath.toString() + " not exists anymore");
|
||||
return new RemoteOperationResult(ResultCode.LOCAL_FILE_NOT_FOUND);
|
||||
}
|
||||
|
||||
try {
|
||||
/// check the existence of the parent folder for the file to upload
|
||||
String remoteParentPath = new File(getRemotePath()).getParent();
|
||||
|
|
|
@ -34,6 +34,7 @@ import android.widget.ImageButton;
|
|||
import android.widget.ImageView;
|
||||
import android.widget.ProgressBar;
|
||||
import android.widget.TextView;
|
||||
import android.widget.Toast;
|
||||
|
||||
import com.owncloud.android.R;
|
||||
import com.owncloud.android.authentication.AuthenticatorActivity;
|
||||
|
@ -304,6 +305,10 @@ public class ExpandableUploadListAdapter extends BaseExpandableListAdapter imple
|
|||
status = mParentActivity.getString(
|
||||
R.string.uploads_view_upload_status_failed_folder_error);
|
||||
break;
|
||||
case FILE_NOT_FOUND:
|
||||
status = mParentActivity.getString(
|
||||
R.string.uploads_view_upload_status_failed_localfile_error);
|
||||
break;
|
||||
case FILE_ERROR:
|
||||
status = mParentActivity.getString(
|
||||
R.string.uploads_view_upload_status_failed_file_error);
|
||||
|
@ -411,7 +416,13 @@ public class ExpandableUploadListAdapter extends BaseExpandableListAdapter imple
|
|||
view.setOnClickListener(new OnClickListener() {
|
||||
@Override
|
||||
public void onClick(View v) {
|
||||
mParentActivity.getFileOperationsHelper().retryUpload(upload);
|
||||
File file = new File(upload.getLocalPath());
|
||||
if (file.exists())
|
||||
mParentActivity.getFileOperationsHelper().retryUpload(upload);
|
||||
else {
|
||||
final String message = String.format(mParentActivity.getString(R.string.local_file_not_found_toast));
|
||||
Toast.makeText(mParentActivity, message, Toast.LENGTH_SHORT).show();
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue