1
0
Fork 0
mirror of https://github.com/syncthing/syncthing-android.git synced 2025-01-07 10:42:07 +00:00

Send a shutdown POST request first (fixes #320) (#323)

* 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:
Catfriend1 2019-02-12 02:22:34 +01:00 committed by GitHub
parent cf94716059
commit 88677c9638
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
3 changed files with 13 additions and 0 deletions

View file

@ -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,

View file

@ -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.
*/

View file

@ -658,6 +658,9 @@ public class SyncthingService extends Service {
}
if (mRestApi != null) {
if (mSyncthingRunnable != null) {
mRestApi.shutdown();
}
mRestApi = null;
}