diff options
-rw-r--r-- | src/main/java/com/googlesource/gerrit/plugins/replication/Destination.java | 28 |
1 files changed, 18 insertions, 10 deletions
diff --git a/src/main/java/com/googlesource/gerrit/plugins/replication/Destination.java b/src/main/java/com/googlesource/gerrit/plugins/replication/Destination.java index 19a9359..d80da48 100644 --- a/src/main/java/com/googlesource/gerrit/plugins/replication/Destination.java +++ b/src/main/java/com/googlesource/gerrit/plugins/replication/Destination.java @@ -197,25 +197,29 @@ class Destination { return cfg.getInt("remote", rc.getName(), name, defValue); } - void schedule(final Project.NameKey project, final String ref, - final URIish uri, ReplicationState state) { + private boolean isVisible(final Project.NameKey project, + ReplicationState... states) { try { - boolean visible = threadScoper.scope(new Callable<Boolean>(){ + return threadScoper.scope(new Callable<Boolean>() { @Override public Boolean call() throws NoSuchProjectException { return controlFor(project).isVisible(); } }).call(); - if (!visible) { - return; - } } catch (NoSuchProjectException err) { - wrappedLog.error(String.format( - "source project %s not available", project), err, state); - return; + wrappedLog.error(String.format("source project %s not available", project), + err, states); } catch (Exception e) { throw Throwables.propagate(e); } + return false; + } + + void schedule(final Project.NameKey project, final String ref, + final URIish uri, ReplicationState state) { + if (!isVisible(project, state)) { + return; + } if (!replicatePermissions) { PushOne e; @@ -377,7 +381,11 @@ class Destination { } } - boolean wouldPushProject(Project.NameKey project) { + boolean wouldPushProject(final Project.NameKey project) { + if (!isVisible(project)) { + return false; + } + // by default push all projects if (projects.length < 1) { return true; |