mirror of
https://github.com/syncthing/syncthing-android.git
synced 2025-01-07 10:42:07 +00:00
* Move notificationHandler shutdown from RestApi to SyncthingService * http/PostRequest: Add shutdown uri * Add RestApi#shutdown to post a shutdown request (fixes #320) * SyncthingService#shutdown: Send a shutdown POST request first in case the kill via shell fails (fixes #320)
This commit is contained in:
parent
cf94716059
commit
88677c9638
3 changed files with 13 additions and 0 deletions
|
@ -16,6 +16,7 @@ public class PostRequest extends ApiRequest {
|
|||
public static final String URI_DB_IGNORES = "/rest/db/ignores";
|
||||
public static final String URI_DB_OVERRIDE = "/rest/db/override";
|
||||
public static final String URI_SYSTEM_CONFIG = "/rest/system/config";
|
||||
public static final String URI_SYSTEM_SHUTDOWN = "/rest/system/shutdown";
|
||||
|
||||
public PostRequest(Context context, URL url, String path, String apiKey,
|
||||
@Nullable Map<String, String> params, @Nullable String postBody,
|
||||
|
|
|
@ -410,6 +410,15 @@ public class RestApi {
|
|||
mOnConfigChangedListener.onConfigChanged();
|
||||
}
|
||||
|
||||
/**
|
||||
* Posts shutdown request.
|
||||
* This will cause SyncthingNative to exit and not restart.
|
||||
*/
|
||||
public void shutdown() {
|
||||
new PostRequest(mContext, mUrl, PostRequest.URI_SYSTEM_SHUTDOWN, mApiKey,
|
||||
null, null, null);
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the version name, or a (text) error message on failure.
|
||||
*/
|
||||
|
|
|
@ -658,6 +658,9 @@ public class SyncthingService extends Service {
|
|||
}
|
||||
|
||||
if (mRestApi != null) {
|
||||
if (mSyncthingRunnable != null) {
|
||||
mRestApi.shutdown();
|
||||
}
|
||||
mRestApi = null;
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in a new issue