mirror of
https://github.com/m1k1o/neko-rooms.git
synced 2026-11-03 07:01:35 -06:00
switch layers to slice.
This commit is contained in:
+2
-2
@@ -548,8 +548,8 @@ components:
|
||||
format: datetime
|
||||
example: "2021-03-07T21:56:34Z"
|
||||
layers:
|
||||
type: object
|
||||
additionalProperties:
|
||||
type: array
|
||||
items:
|
||||
$ref: '#/components/schemas/PullLayer'
|
||||
status:
|
||||
type: array
|
||||
|
||||
@@ -195,10 +195,10 @@ export interface PullStatus {
|
||||
'started'?: string;
|
||||
/**
|
||||
*
|
||||
* @type {{ [key: string]: PullLayer; }}
|
||||
* @type {Array<PullLayer>}
|
||||
* @memberof PullStatus
|
||||
*/
|
||||
'layers'?: { [key: string]: PullLayer; };
|
||||
'layers'?: Array<PullLayer>;
|
||||
/**
|
||||
*
|
||||
* @type {Array<string>}
|
||||
|
||||
@@ -15,7 +15,7 @@
|
||||
Pull neko images
|
||||
</v-card-title>
|
||||
<v-card-text>
|
||||
<template v-if="status.active && status.layers && Object.keys(status.layers).length > 0">
|
||||
<template v-if="status.active && status.layers && status.layers.length > 0">
|
||||
<pre v-for="layer in status.layers" :key="layer.id">{{ layer.id }} {{ layer.status }}{{ layer.progress && ' ' + layer.progress }}</pre>
|
||||
<br />
|
||||
</template>
|
||||
|
||||
+11
-2
@@ -18,6 +18,7 @@ type PullConfig struct {
|
||||
mu sync.Mutex
|
||||
cancel func()
|
||||
status types.PullStatus
|
||||
layers map[string]int
|
||||
}
|
||||
|
||||
func (pull *PullConfig) TryInitialize(cancel func()) bool {
|
||||
@@ -35,10 +36,12 @@ func (pull *PullConfig) TryInitialize(cancel func()) bool {
|
||||
pull.status = types.PullStatus{
|
||||
Active: true,
|
||||
Started: &now,
|
||||
Layers: map[string]types.PullLayer{},
|
||||
Layers: []types.PullLayer{},
|
||||
Status: []string{},
|
||||
}
|
||||
|
||||
pull.layers = map[string]int{}
|
||||
|
||||
return true
|
||||
}
|
||||
|
||||
@@ -120,7 +123,13 @@ func (manager *RoomManagerCtx) PullStart(request types.PullStart) error {
|
||||
}
|
||||
|
||||
if layer.ProgressDetail != nil {
|
||||
manager.pull.status.Layers[layer.ID] = layer
|
||||
// map layer id to slice index
|
||||
if index, ok := manager.pull.layers[layer.ID]; ok {
|
||||
manager.pull.status.Layers[index] = layer
|
||||
} else {
|
||||
manager.pull.layers[layer.ID] = len(manager.pull.layers)
|
||||
manager.pull.status.Layers = append(manager.pull.status.Layers, layer)
|
||||
}
|
||||
} else {
|
||||
manager.pull.status.Status = append(
|
||||
manager.pull.status.Status,
|
||||
|
||||
@@ -262,11 +262,11 @@ type PullLayer struct {
|
||||
}
|
||||
|
||||
type PullStatus struct {
|
||||
Active bool `json:"active"`
|
||||
Started *time.Time `json:"started"`
|
||||
Layers map[string]PullLayer `json:"layers"`
|
||||
Status []string `json:"status"`
|
||||
Finished *time.Time `json:"finished"`
|
||||
Active bool `json:"active"`
|
||||
Started *time.Time `json:"started"`
|
||||
Layers []PullLayer `json:"layers"`
|
||||
Status []string `json:"status"`
|
||||
Finished *time.Time `json:"finished"`
|
||||
}
|
||||
|
||||
type RoomManager interface {
|
||||
|
||||
Reference in New Issue
Block a user