mirror of
https://github.com/garethgeorge/backrest.git
synced 2026-08-26 10:56:33 +00:00
fix: misc bugs related to new logref support
This commit is contained in:
@@ -11,7 +11,11 @@
|
||||
"NODE_VERSION": "lts/*"
|
||||
}
|
||||
},
|
||||
"runArgs": ["--cap-add=SYS_PTRACE", "--security-opt", "seccomp=unconfined"],
|
||||
"runArgs": [
|
||||
"--cap-add=SYS_PTRACE",
|
||||
"--security-opt",
|
||||
"seccomp=unconfined"
|
||||
],
|
||||
"customizations": {
|
||||
"vscode": {
|
||||
// Set *default* container specific settings.json values on container create.
|
||||
@@ -38,10 +42,8 @@
|
||||
},
|
||||
// Use 'forwardPorts' to make a list of ports inside the container available locally.
|
||||
// "forwardPorts": [],
|
||||
|
||||
// Use 'postCreateCommand' to run commands after the container is created.
|
||||
// "postCreateCommand": "go version",
|
||||
|
||||
// Comment out connect as root instead. More info: https://aka.ms/vscode-remote/containers/non-root.
|
||||
"remoteUser": "vscode"
|
||||
}
|
||||
}
|
||||
@@ -541,6 +541,7 @@ func (s *BackrestHandler) GetLogs(ctx context.Context, req *connect.Request[v1.L
|
||||
}
|
||||
return fmt.Errorf("get log data %v: %w", req.Msg.GetRef(), err)
|
||||
}
|
||||
defer s.logStore.Unsubscribe(req.Msg.Ref, ch)
|
||||
|
||||
doneCh := make(chan struct{})
|
||||
|
||||
@@ -550,20 +551,12 @@ func (s *BackrestHandler) GetLogs(ctx context.Context, req *connect.Request[v1.L
|
||||
defer interval.Stop()
|
||||
|
||||
go func() {
|
||||
for {
|
||||
select {
|
||||
case data, ok := <-ch:
|
||||
if !ok {
|
||||
close(doneCh)
|
||||
return
|
||||
}
|
||||
mu.Lock()
|
||||
buf.Write(data)
|
||||
mu.Unlock()
|
||||
case <-ctx.Done():
|
||||
return
|
||||
}
|
||||
for data := range ch {
|
||||
mu.Lock()
|
||||
buf.Write(data)
|
||||
mu.Unlock()
|
||||
}
|
||||
close(doneCh)
|
||||
}()
|
||||
|
||||
flushHelper := func() error {
|
||||
|
||||
@@ -70,9 +70,14 @@ func (t *LiveLog) Unsubscribe(id string, ch chan []byte) {
|
||||
if w, ok := t.writers[id]; ok {
|
||||
w.mu.Lock()
|
||||
defer w.mu.Unlock()
|
||||
w.subscribers = slices.DeleteFunc(w.subscribers, func(c chan []byte) bool {
|
||||
|
||||
idx := slices.IndexFunc(w.subscribers, func(c chan []byte) bool {
|
||||
return c == ch
|
||||
})
|
||||
if idx >= 0 {
|
||||
close(ch)
|
||||
w.subscribers = append(w.subscribers[:idx], w.subscribers[idx+1:]...)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -194,6 +199,7 @@ func (t *LiveLogWriter) Close() error {
|
||||
for _, ch := range t.subscribers {
|
||||
close(ch)
|
||||
}
|
||||
t.subscribers = nil
|
||||
|
||||
return t.fh.Close()
|
||||
}
|
||||
|
||||
@@ -57,7 +57,10 @@ export const LogView = ({ logref }: { logref: string }) => {
|
||||
}}
|
||||
>
|
||||
{lines.map((line, i) => (
|
||||
<pre style={{ margin: "0px" }} key={i}>
|
||||
<pre
|
||||
style={{ margin: "0px", whiteSpace: "pre", overflow: "visible" }}
|
||||
key={i}
|
||||
>
|
||||
{line}
|
||||
</pre>
|
||||
))}
|
||||
|
||||
@@ -212,6 +212,7 @@ export const OperationRow = ({
|
||||
});
|
||||
} else if (operation.op.case === "operationPrune") {
|
||||
const prune = operation.op.value;
|
||||
expandedBodyItems.push("prune");
|
||||
bodyItems.push({
|
||||
key: "prune",
|
||||
label: "Prune Output",
|
||||
@@ -223,6 +224,7 @@ export const OperationRow = ({
|
||||
});
|
||||
} else if (operation.op.case === "operationCheck") {
|
||||
const check = operation.op.value;
|
||||
expandedBodyItems.push("check");
|
||||
bodyItems.push({
|
||||
key: "check",
|
||||
label: "Check Output",
|
||||
@@ -242,6 +244,9 @@ export const OperationRow = ({
|
||||
} else if (operation.op.case === "operationRunHook") {
|
||||
const hook = operation.op.value;
|
||||
if (operation.logref) {
|
||||
if (operation.status === OperationStatus.STATUS_INPROGRESS) {
|
||||
expandedBodyItems.push("logref");
|
||||
}
|
||||
bodyItems.push({
|
||||
key: "logref",
|
||||
label: "Hook Output",
|
||||
|
||||
Reference in New Issue
Block a user