Skip to content

Commit b199344

Browse files
dkocherAliveDevil
andauthored
Remove transcript as parameter.
Co-authored-by: AliveDevil <[email protected]>
1 parent 399a832 commit b199344

File tree

10 files changed

+17
-43
lines changed

10 files changed

+17
-43
lines changed

cli/src/main/java/ch/cyberduck/cli/TerminalAlertCallback.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ public class TerminalAlertCallback implements AlertCallback {
2929
private final Console console = new Console();
3030

3131
@Override
32-
public boolean alert(final Host host, final BackgroundException failure, final StringBuilder transcript) {
32+
public boolean alert(final Host host, final BackgroundException failure) {
3333
this.print(failure);
3434
// Never repeat
3535
return false;

cli/src/test/java/ch/cyberduck/cli/TerminalAlertCallbackTest.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,6 @@ public class TerminalAlertCallbackTest {
2929

3030
@Test
3131
public void testAlert() {
32-
assertFalse(new TerminalAlertCallback().alert(new Host(new TestProtocol()), new BackgroundException(), new StringBuilder()));
32+
assertFalse(new TerminalAlertCallback().alert(new Host(new TestProtocol()), new BackgroundException()));
3333
}
3434
}

core/src/main/java/ch/cyberduck/core/notification/NotificationAlertCallback.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ public class NotificationAlertCallback implements AlertCallback {
2828
private final NotificationService notification = NotificationServiceFactory.get();
2929

3030
@Override
31-
public boolean alert(final Host bookmark, final BackgroundException failure, final StringBuilder transcript) {
31+
public boolean alert(final Host bookmark, final BackgroundException failure) {
3232
notification.notify(BookmarkNameProvider.toString(bookmark), bookmark.getUuid(), failure.getMessage(), BookmarkNameProvider.toString(bookmark));
3333
return false;
3434
}

core/src/main/java/ch/cyberduck/core/threading/AlertCallback.java

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -23,12 +23,8 @@
2323

2424
public interface AlertCallback {
2525

26-
default boolean alert(final Host host, final BackgroundException failure) {
27-
return this.alert(host, failure, new StringBuilder());
28-
}
29-
3026
/**
3127
* @return True if action should be repeated
3228
*/
33-
boolean alert(Host host, BackgroundException failure, StringBuilder transcript);
29+
boolean alert(Host host, BackgroundException failure);
3430
}

core/src/main/java/ch/cyberduck/core/threading/DisabledAlertCallback.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ public class DisabledAlertCallback implements AlertCallback {
2828
private static final Logger log = LogManager.getLogger(DisabledAlertCallback.class);
2929

3030
@Override
31-
public boolean alert(final Host host, final BackgroundException failure, final StringBuilder transcript) {
31+
public boolean alert(final Host host, final BackgroundException failure) {
3232
log.warn("Ignore failure {}", failure.getMessage());
3333
return false;
3434
}

core/src/main/java/ch/cyberduck/core/threading/SessionBackgroundAction.java

Lines changed: 4 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -21,28 +21,21 @@
2121
import ch.cyberduck.core.BookmarkNameProvider;
2222
import ch.cyberduck.core.ProgressListener;
2323
import ch.cyberduck.core.Session;
24-
import ch.cyberduck.core.TranscriptListener;
2524
import ch.cyberduck.core.exception.BackgroundException;
2625
import ch.cyberduck.core.pool.SessionPool;
2726

2827
import org.apache.commons.lang3.StringUtils;
2928
import org.apache.logging.log4j.LogManager;
3029
import org.apache.logging.log4j.Logger;
3130

32-
public abstract class SessionBackgroundAction<T> extends AbstractBackgroundAction<T> implements ProgressListener, TranscriptListener {
31+
public abstract class SessionBackgroundAction<T> extends AbstractBackgroundAction<T> implements ProgressListener {
3332
private static final Logger log = LogManager.getLogger(SessionBackgroundAction.class);
3433

3534
/**
3635
* This action encountered one or more exceptions
3736
*/
3837
private BackgroundException failure;
3938

40-
/**
41-
* Contains the transcript of the session while this action was running
42-
*/
43-
private final StringBuffer transcript
44-
= new StringBuffer();
45-
4639
private static final String LINE_SEPARATOR
4740
= System.lineSeparator();
4841

@@ -64,14 +57,6 @@ public void message(final String message) {
6457
progress.message(message);
6558
}
6659

67-
/**
68-
* Append to the transcript and notify listeners.
69-
*/
70-
@Override
71-
public void log(final Type request, final String message) {
72-
transcript.append(message).append(LINE_SEPARATOR);
73-
}
74-
7560
@Override
7661
public void prepare() {
7762
super.prepare();
@@ -112,7 +97,7 @@ public T call() throws BackgroundException {
11297
public T run() throws BackgroundException {
11398
final Session<?> session;
11499
try {
115-
session = pool.borrow(this).withListener(this);
100+
session = pool.borrow(this);
116101
}
117102
catch(BackgroundException e) {
118103
failure = e;
@@ -126,7 +111,7 @@ public T run() throws BackgroundException {
126111
throw e;
127112
}
128113
finally {
129-
pool.release(session.removeListener(this), failure);
114+
pool.release(session, failure);
130115
}
131116
}
132117

@@ -140,12 +125,11 @@ public boolean alert(final BackgroundException failure) {
140125
}
141126
log.info("Run alert callback {} for failure {}", alert, failure);
142127
// Display alert if the action was not canceled intentionally
143-
return alert.alert(pool.getHost(), failure, new StringBuilder(transcript.toString()));
128+
return alert.alert(pool.getHost(), failure);
144129
}
145130

146131
@Override
147132
public void cleanup(final T result, final BackgroundException failure) {
148-
transcript.setLength(0);
149133
this.message(StringUtils.EMPTY);
150134
super.cleanup(result, failure);
151135
}

core/src/test/java/ch/cyberduck/core/threading/SessionBackgroundActionTest.java

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -68,7 +68,7 @@ public void testGetExceptionFailure() {
6868
new TestLoginConnectionService(), new NullSession(new Host(new TestProtocol(), "t")),
6969
new DisabledTranscriptListener(), new DefaultVaultRegistry(new DisabledPasswordCallback())), new AlertCallback() {
7070
@Override
71-
public boolean alert(final Host repeatableBackgroundAction, final BackgroundException f, final StringBuilder transcript) {
71+
public boolean alert(final Host repeatableBackgroundAction, final BackgroundException f) {
7272
assertEquals(failure, f);
7373
return false;
7474
}
@@ -95,7 +95,7 @@ public void testGetExceptionLoginCanceledException() {
9595
new TestLoginConnectionService(), new NullSession(new Host(new TestProtocol(), "t")),
9696
new DisabledTranscriptListener(), new DefaultVaultRegistry(new DisabledPasswordCallback())), new AlertCallback() {
9797
@Override
98-
public boolean alert(final Host repeatableBackgroundAction, final BackgroundException f, final StringBuilder transcript) {
98+
public boolean alert(final Host repeatableBackgroundAction, final BackgroundException f) {
9999
assertEquals(failure, f);
100100
return false;
101101
}
@@ -124,7 +124,7 @@ public void testRetrySocket() {
124124
new NullSession(new Host(new TestProtocol(), "t")),
125125
new DisabledTranscriptListener(), new DefaultVaultRegistry(new DisabledPasswordCallback())), new AlertCallback() {
126126
@Override
127-
public boolean alert(final Host repeatableBackgroundAction, final BackgroundException f, final StringBuilder transcript) {
127+
public boolean alert(final Host repeatableBackgroundAction, final BackgroundException f) {
128128
assertEquals(failure, f);
129129
return false;
130130
}

osx/src/main/java/ch/cyberduck/ui/cocoa/callback/PromptAlertCallback.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -39,15 +39,15 @@ public PromptAlertCallback(final WindowController parent) {
3939
}
4040

4141
@Override
42-
public boolean alert(final Host host, final BackgroundException failure, final StringBuilder transcript) {
42+
public boolean alert(final Host host, final BackgroundException failure) {
4343
final FailureDiagnostics.Type type = new DefaultFailureDiagnostics().determine(failure);
4444
switch(type) {
4545
case cancel:
4646
case skip:
4747
return false;
4848
default:
4949
// Send notification
50-
notification.alert(host, failure, transcript);
50+
notification.alert(host, failure);
5151
// Run prompt
5252
final AlertController alert = new BackgroundExceptionAlertController(failure, host);
5353
switch(alert.beginSheet(parent)) {

osx/src/main/java/ch/cyberduck/ui/cocoa/controller/BrowserController.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3217,7 +3217,7 @@ public void openTerminalButtonClicked(final ID sender) {
32173217
terminal.open(pool.getHost(), workdir);
32183218
}
32193219
catch(AccessDeniedException e) {
3220-
new PromptAlertCallback(this).alert(pool.getHost(), e, new StringBuilder());
3220+
new PromptAlertCallback(this).alert(pool.getHost(), e);
32213221
}
32223222
}
32233223

windows/src/main/csharp/ch/cyberduck/ui/winforms/threading/DialogAlertCallback.cs

Lines changed: 2 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -41,11 +41,6 @@ public DialogAlertCallback(IWindowController controller)
4141
}
4242

4343
public bool alert(Host host, BackgroundException failure)
44-
{
45-
return alert(host, failure, new StringBuilder());
46-
}
47-
48-
public bool alert(Host host, BackgroundException failure, StringBuilder log)
4944
{
5045
FailureDiagnostics.Type type = _diagnostics.determine(failure);
5146
if (type == FailureDiagnostics.Type.cancel)
@@ -56,15 +51,14 @@ public bool alert(Host host, BackgroundException failure, StringBuilder log)
5651
{
5752
return false;
5853
}
59-
_notification.alert(host, failure, log);
54+
_notification.alert(host, failure);
6055
bool r = false;
6156
_controller.Invoke(delegate
6257
{
6358
string footer = ProviderHelpServiceFactory.get().help(host.getProtocol());
6459
string title = BookmarkNameProvider.toString(host);
6560
string message = failure.getMessage() ?? LocaleFactory.localizedString("Unknown");
6661
string detail = failure.getDetail() ?? LocaleFactory.localizedString("Unknown");
67-
string expanded = log.length() > 0 ? log.toString() : null;
6862
string commandButtons;
6963
if (type == FailureDiagnostics.Type.network)
7064
{
@@ -86,7 +80,7 @@ public bool alert(Host host, BackgroundException failure, StringBuilder log)
8680
title: title,
8781
mainInstruction: message,
8882
content: detail,
89-
expandedInfo: expanded,
83+
expandedInfo: null,
9084
help: footer,
9185
verificationText: null,
9286
commandButtons: commandButtons,

0 commit comments

Comments
 (0)