Merge pull request #948 from nextcloud/removedSDcard

if source folder does not exist, still allow to move to new folder
This commit is contained in:
Tobias Kaminsky 2017-05-04 11:31:29 +02:00 committed by GitHub
commit 0dc729105d
3 changed files with 40 additions and 7 deletions

View file

@ -81,9 +81,11 @@ public class DownloadFileOperation extends RemoteOperation {
}
public String getSavePath() {
String path = mFile.getStoragePath(); // re-downloads should be done over the original file
if (path != null && path.length() > 0) {
return path;
if (mFile.getStoragePath() != null) {
File path = new File(mFile.getStoragePath()); // re-downloads should be done over the original file
if (path.canWrite()) {
return path.getAbsolutePath();
}
}
return FileStorageUtils.getDefaultSavePathFor(mAccount.name, mFile);
}

View file

@ -205,8 +205,14 @@ public class StorageMigration {
if (succeed) {
mProgressDialog.hide();
} else {
mProgressDialog.getButton(ProgressDialog.BUTTON_POSITIVE).setVisibility(View.VISIBLE);
mProgressDialog.setIndeterminateDrawable(mContext.getResources().getDrawable(R.drawable.image_fail));
if (code == R.string.file_migration_failed_not_readable) {
mProgressDialog.hide();
askToStillMove();
} else {
mProgressDialog.getButton(ProgressDialog.BUTTON_POSITIVE).setVisibility(View.VISIBLE);
mProgressDialog.setIndeterminateDrawable(mContext.getResources().getDrawable(R.drawable.image_fail));
}
}
if (mListener != null) {
@ -214,6 +220,28 @@ public class StorageMigration {
}
}
private void askToStillMove() {
new AlertDialog.Builder(mContext)
.setTitle(R.string.file_migration_source_not_readable_title)
.setMessage(mContext.getString(R.string.file_migration_source_not_readable, mStorageTarget))
.setNegativeButton(R.string.common_no, new OnClickListener() {
@Override
public void onClick(DialogInterface dialogInterface, int i) {
dialogInterface.dismiss();
}
})
.setPositiveButton(R.string.common_yes, new OnClickListener() {
@Override
public void onClick(DialogInterface dialogInterface, int i) {
if (mListener != null) {
mListener.onStorageMigrationFinished(mStorageTarget, true);
}
}
})
.create()
.show();
}
protected boolean[] saveAccountsSyncStatus() {
boolean[] syncs = new boolean[mOcAccounts.length];
for (int i = 0; i < mOcAccounts.length; ++i) {

View file

@ -412,8 +412,8 @@
<string name="file_migration_restoring_accounts_configuration">Restoring configuration of accounts&#8230;</string>
<string name="file_migration_ok_finished">Finished</string>
<string name="file_migration_failed_not_enough_space">ERROR: Insufficient space</string>
<string name="file_migration_failed_not_writable">ERROR: File not writable</string>
<string name="file_migration_failed_not_readable">ERROR: File not readable</string>
<string name="file_migration_failed_not_writable">ERROR: Destination file not writable</string>
<string name="file_migration_failed_not_readable">ERROR: Source file not readable</string>
<string name="file_migration_failed_dir_already_exists">ERROR: Nextcloud directory already exists</string>
<string name="file_migration_failed_while_coping">ERROR: Failed during migration</string>
<string name="file_migration_failed_while_updating_index">ERROR: Failed to updating index</string>
@ -422,6 +422,9 @@
<string name="file_migration_override_data_folder">Replace</string>
<string name="file_migration_use_data_folder">Use</string>
<string name="file_migration_source_not_readable_title">Source directory not readable!</string>
<string name="file_migration_source_not_readable">Do you still want to change the storage path to %1$s?\n\nNote: all data will have to be downloaded again.</string>
<string name="prefs_category_accounts">Accounts</string>
<string name="prefs_add_account">Add account</string>
<string name="drawer_manage_accounts">Manage accounts</string>