Skip to content
This repository has been archived by the owner on Jul 26, 2022. It is now read-only.

Commit

Permalink
Merge pull request #186 from syncany/bugfix/cli-daemon-interaction
Browse files Browse the repository at this point in the history
Bugfix/cli daemon interaction
  • Loading branch information
binwiederhier committed Aug 6, 2014
2 parents 635e8be + e877b68 commit c8f6fd5
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 8 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -229,7 +229,9 @@ private void handleCliRequest(CliRequest cliRequest) {
handleCliRequestSyncRunning(cliRequest);
}
else {
watchOperation.pause();
handleCliRequestNoSyncRunning(cliRequest);
watchOperation.resume();
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -131,14 +131,12 @@ public WatchOperationResult execute() {
}

syncLoop: while (!stopRequested.get()) {
while (pauseRequested.get()) {
try {
Thread.sleep(1000);
}
catch (InterruptedException e) {
logger.log(Level.INFO, "Sleep INTERRUPTED during PAUSE. STOPPING.", e);
break syncLoop;
}
try {
waitWhilePaused();
}
catch (InterruptedException e) {
logger.log(Level.INFO, "Sleep INTERRUPTED during PAUSE. STOPPING.", e);
break syncLoop;
}

try {
Expand Down Expand Up @@ -243,6 +241,7 @@ private void runSync() throws Exception {

logger.log(Level.INFO, "RUNNING SYNC ...");


try {
boolean notifyChanges = false;

Expand Down Expand Up @@ -298,6 +297,7 @@ private void runSync() throws Exception {
public void pushNotificationReceived(String channel, String message) {
if (channel.equals(notificationChannel) && !message.equals(notificationInstanceId)) {
try {
waitWhilePaused();
runSync();
}
catch (Exception e) {
Expand All @@ -309,6 +309,7 @@ public void pushNotificationReceived(String channel, String message) {
@Override
public void watchEventsOccurred() {
try {
waitWhilePaused();
runSync();
}
catch (Exception e) {
Expand Down Expand Up @@ -355,6 +356,12 @@ public boolean isSyncRunning() {
public boolean isSyncRequested() {
return syncRequested.get();
}

private void waitWhilePaused() throws InterruptedException {
while (pauseRequested.get()) {
Thread.sleep(1000);
}
}

private void scheduleForceKill() {
String killTimerName = "KillTim/" + config.getLocalDir().getName();
Expand Down

0 comments on commit c8f6fd5

Please sign in to comment.