1
0
Fork 0
mirror of https://github.com/syncthing/syncthing-android.git synced 2025-01-11 04:25:53 +00:00

Shutdown syncthing before importing a config (fixes #570).

This commit is contained in:
Felix Ableitner 2016-03-12 19:30:38 +01:00
parent fc5827a1df
commit b9c76ff062
3 changed files with 7 additions and 2 deletions

View file

@ -381,7 +381,8 @@ public class SettingsFragment extends PreferenceFragment
Toast.makeText(getActivity(),
getString(R.string.config_imported_successful),
Toast.LENGTH_SHORT).show();
mSyncthingService.getApi().requireRestart(getActivity());
// No need to restart, as we shutdown to import the config, and
// then have to start Syncthing again.
} else {
Toast.makeText(getActivity(),
getString(R.string.config_import_failed,

View file

@ -136,7 +136,7 @@ public class SyncthingRunnable implements Runnable {
lInfo.join();
lWarn.join();
// Restart if that was requested.
// Restart if that was requested via Rest API call.
if (ret == 3) {
Log.i(TAG, "Restarting syncthing");
mContext.startService(new Intent(mContext, SyncthingService.class)

View file

@ -606,6 +606,8 @@ public class SyncthingService extends Service implements
* @return True if the import was successful, false otherwise (eg if files aren't found).
*/
public boolean importConfig() {
mCurrentState = State.DISABLED;
shutdown();
File config = new File(EXPORT_PATH, ConfigXml.CONFIG_FILE);
File privateKey = new File(EXPORT_PATH, PRIVATE_KEY_FILE);
File publicKey = new File(EXPORT_PATH, PUBLIC_KEY_FILE);
@ -615,6 +617,8 @@ public class SyncthingService extends Service implements
copyFile(config, new File(getFilesDir(), ConfigXml.CONFIG_FILE));
copyFile(privateKey, new File(getFilesDir(), PRIVATE_KEY_FILE));
copyFile(publicKey, new File(getFilesDir(), PUBLIC_KEY_FILE));
mCurrentState = State.INIT;
updateState();
return true;
}