Skip to content

Commit

Permalink
Merge branch 'master' of https://github.com/pydio/cells
Browse files Browse the repository at this point in the history
  • Loading branch information
cdujeu committed Sep 30, 2021
2 parents 202a1f2 + f23407e commit cde07cf
Show file tree
Hide file tree
Showing 12 changed files with 113 additions and 45 deletions.
4 changes: 2 additions & 2 deletions cmd/root.go
Original file line number Diff line number Diff line change
Expand Up @@ -116,10 +116,10 @@ WORKING DIRECTORIES
LOGS LEVEL
By default, logs are outputted in console format at the Info level and appended in a CELLS_LOG_DIR/pydio.log file. You can:
By default, logs are outputted in console format at the Info level and appended to a CELLS_LOG_DIR/pydio.log file. You can:
- Change the level (debug, info, warn or error) with the --log flag or the CELLS_LOGS_LEVEL environment variable
- Output the logs in json format with --log_json=true
- Prevent logs to be written in file with --log_to_file=false
- Prevent logs from being written to a file with --log_to_file=false
For backward compatibility, --log=production still works and is equivalent to "--log=info --log_json=true --log_to_file=true"
Expand Down
56 changes: 47 additions & 9 deletions common/config/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -91,9 +91,7 @@ func New(store configx.Entrypoint) Store {
continue
}

im := configx.New(configx.WithJSON())
im.Set(resp)
ret.im = im
ret.im.Set(resp)
}
}()

Expand Down Expand Up @@ -171,7 +169,7 @@ func (c *cacheconfig) Del() error {
}

func (c *cacheconfig) Val(k ...string) configx.Values {
return &cacheValues{c.im.Val(k...), c.store, k}
return &cacheValues{c.im, c.store, k}
}

type cacheValues struct {
Expand All @@ -181,16 +179,17 @@ type cacheValues struct {
}

func (c *cacheValues) Val(s ...string) configx.Values {
return &cacheValues{c.Values.Val(s...), c.store, append(c.path, s...)}
path := configx.StringToKeys(append(c.path, s...)...)
return &cacheValues{c.Values, c.store, path}
}

func (c *cacheValues) Get() configx.Value {
return c.Values.Get()
return c.Values.Val(c.path...).Get()
}

// We store it in the cache and in the store
func (c *cacheValues) Set(v interface{}) error {
err := c.Values.Set(v)
err := c.Values.Val(c.path...).Set(v)
if err != nil {
return err
}
Expand All @@ -199,14 +198,53 @@ func (c *cacheValues) Set(v interface{}) error {
}

func (c *cacheValues) Del() error {
err := c.Values.Del()
err := c.Values.Val(c.path...).Del()
if err != nil {
return err
}

return c.store.Val(c.path...).Del()
}

func (c *cacheValues) Default(i interface{}) configx.Value {
return c.Values.Val(c.path...).Default(i)
}

func (c *cacheValues) String() string {
return c.Values.Val(c.path...).String()
}

func (c *cacheValues) MarshalJSON() ([]byte, error) {
return []byte(c.Values.String()), nil
return []byte(c.Values.Val(c.path...).String()), nil
}

func (c *cacheValues) Bool() bool {
return c.Values.Val(c.path...).Bool()
}
func (c *cacheValues) Bytes() []byte {
return c.Values.Val(c.path...).Bytes()
}
func (c *cacheValues) Int() int {
return c.Values.Val(c.path...).Int()
}
func (c *cacheValues) Int64() int64 {
return c.Values.Val(c.path...).Int64()
}
func (c *cacheValues) Duration() time.Duration {
return c.Values.Val(c.path...).Duration()
}
func (c *cacheValues) StringMap() map[string]string {
return c.Values.Val(c.path...).StringMap()
}
func (c *cacheValues) StringArray() []string {
return c.Values.Val(c.path...).StringArray()
}
func (c *cacheValues) Slice() []interface{} {
return c.Values.Val(c.path...).Slice()
}
func (c *cacheValues) Map() map[string]interface{} {
return c.Values.Val(c.path...).Map()
}
func (c *cacheValues) Scan(i interface{}) error {
return c.Values.Val(c.path...).Scan(i)
}
7 changes: 5 additions & 2 deletions common/config/config_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,6 @@
package config

import (
"fmt"
"sync"
"testing"

Expand All @@ -45,8 +44,12 @@ func TestConfig(t *testing.T) {
Get("test/bool1").Del()
// Get("test/bool2").Del()
Save("test", "test")
})

fmt.Println(Get("test").Map())
Convey("Test setting", t, func() {
c := Get().Val("test/test/test")
Set("test1", "test/test/test/test1")
So(c.Val("test1").String(), ShouldEqual, "test1")
})

Convey("Test Watch", t, func() {
Expand Down
6 changes: 4 additions & 2 deletions common/config/raft/raft.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,10 +18,12 @@ import (
"context"
"encoding/json"
"fmt"
"github.com/pydio/cells/common/config"
"log"
"net/http"
"net/url"
"os"
"path/filepath"
"sort"
"strconv"
"time"
Expand Down Expand Up @@ -377,7 +379,7 @@ func (rc *raftNode) startRaft() {
rc.memberID = member.ID

// Creating snap dir
rc.snapdir = "service-" + member.ID.String() + "-snap"
rc.snapdir = filepath.Join(config.ApplicationWorkingDir(), "service-" + member.ID.String() + "-snap")
if !fileutil.Exist(rc.snapdir) {
if err := os.Mkdir(rc.snapdir, 0750); err != nil {
log.Fatalf("raftexample: cannot create dir for snapshot (%v)", err)
Expand All @@ -387,7 +389,7 @@ func (rc *raftNode) startRaft() {
rc.snapshotter = snap.New(rc.logger, rc.snapdir)

// Creating waldir
rc.waldir = "service-" + member.ID.String()
rc.waldir = filepath.Join(config.ApplicationWorkingDir() + "service-" + member.ID.String())

hasWAL := wal.Exist(rc.waldir)

Expand Down
7 changes: 6 additions & 1 deletion common/service/service.go
Original file line number Diff line number Diff line change
Expand Up @@ -247,9 +247,14 @@ var mandatoryOptions = []ServiceOption{
s.Init(Watch(func(_ Service, c configx.Values) {
s.Stop()

ctx := s.Options().Context
//fmt.Println("In context ? ", config.Get("services", s.Name()))
//ctx = servicecontext.WithConfig(ctx, config.Get("services", s.Name()))
//s.Init(Context(ctx))

<-time.After(1 * time.Second)

s.Start(s.Options().Context)
s.Start(ctx)
}))
}

Expand Down
4 changes: 3 additions & 1 deletion data/search/grpc/plugins.go
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ package grpc

import (
"context"
servicecontext "github.com/pydio/cells/common/service/context"
"path/filepath"

"github.com/micro/go-micro"
Expand Down Expand Up @@ -59,7 +60,8 @@ func init() {
service.Fork(true),
service.WithMicro(func(m micro.Service) error {

cfg := config.Get("services", Name)
ctx := m.Options().Context
cfg := servicecontext.GetConfig(ctx)

indexContent := cfg.Val("indexContent").Bool()
if indexContent {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -39,10 +39,10 @@
"other": "Fontes de dados %s"
},
"ds.format-picker.title": {
"other": "Create DataSource"
"other": "Criar Fonte de Dados"
},
"ds.format-picker.legend": {
"other": "DataSources are mount points allowing you to attach actual storage to the application. First select the way data is organized inside storage."
"other": "Fontes de Dados são pontos de montagem permitindo que você anexe o armazenamento real ao aplicativo. Primeiro selecione a maneira como os dados são organizados dentro do armazenamento."
},
"ds.format-picker.submit": {
"other": "Inicio"
Expand All @@ -51,19 +51,19 @@
"other": "Armazenamento plano"
},
"ds.format-picker.flat.legend": {
"other": "Best for performances, files are stored as binaries inside the storage. Files and folders structure is kept in internal index only."
"other": "O melhor para desempenho, os arquivos são armazenados como binários dentro do armazenamento. A estrutura dos arquivos e pastas é mantida apenas no índice interno."
},
"ds.format-picker.structured.title": {
"other": "Import Existing Data"
"other": "Importar dados existentes"
},
"ds.format-picker.structured.legend": {
"other": "Files and folders are stored as-is, real-time synchronisation reflects storage structure inside internal indexes."
"other": "Arquivos e pastas são armazenadas como está, sincronização em tempo real reflete a estrutura de armazenamento dentro de índices internos."
},
"ds.format-picker.internal.title": {
"other": "Cells Internals"
"other": "Células Internas"
},
"ds.format-picker.internal.legend": {
"other": "Used to store internal binaries (e.g. files versions, thumbnails). Limited features, data is not indexed in search engines."
"other": "Usado para armazenar binários internos (por exemplo, versões de arquivos, miniaturas). Recursos limitados, dados não são indexados nos mecanismos de busca."
},
"ds.editor.delete.warning": {
"other": "Tem certeza que deseja excluir esta informação? Isso não pode ser desfeito, e você pode perder todos os dados vinculados a estes nós!"
Expand Down Expand Up @@ -357,13 +357,13 @@
"other": "Tipo de armazenamento"
},
"ds.editor.tab.lifecycle": {
"other": "Data Lifecycle"
"other": "Ciclo de vida de dados"
},
"ds.editor.tab.advanced": {
"other": "Advanced Options"
"other": "Opções Avançadas"
},
"ds.editor.initFlatFromSnapshot": {
"other": "If this storage was previously used as a flat datasource, initialize it from an existing snapshot file (must be found inside the storage)"
"other": "Se este armazenamento foi usado anteriormente como uma fonte de dados plana, inicialize-o a partir de um arquivo snapshot existente (deve ser encontrado dentro do armazenamento)"
},
"ds.encryption": {
"other": "Criptografado"
Expand Down Expand Up @@ -531,7 +531,7 @@
"other": "Para"
},
"logs.filter.period.time": {
"other": "At..."
"other": "Em..."
},
"logs.filter.login": {
"other": "Usuário"
Expand All @@ -543,16 +543,16 @@
"other": "Pesquisa em texto"
},
"logs.tz.tooltip": {
"other": "Show local/server timezone"
"other": "Mostrar fuso horário local/servidor"
},
"logs.tz.local": {
"other": "Local Timezone"
"other": "Fuso horário local"
},
"logs.tz.server": {
"other": "Server Timezone"
"other": "Fuso horário do servidor"
},
"logs.toggleTheme": {
"other": "Light/Dark Theme"
"other": "Tema claro/escuro"
},
"logs.sys.note": {
"other": "Nota por favor:"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -195,7 +195,7 @@
"other": "Padrão (lista de arquivos com o cabeçalho da aplicação)"
},
"154": {
"other": "Images Gallery (best for photos)"
"other": "Galeria de Imagens (melhor para fotos)"
},
"155": {
"other": "Embutido (cabeçalho menor, para widgets)"
Expand Down
2 changes: 1 addition & 1 deletion frontend/front-srv/assets/core.pydio/i18n/pt-br.all.json
Original file line number Diff line number Diff line change
Expand Up @@ -2382,7 +2382,7 @@
"other": "Digite um rótulo"
},
"searchengine.field.basenameOrContent": {
"other": "Name/Content"
"other": "Nome/Conteúdo"
},
"chat.load-older": {
"other": "Entradas antigas"
Expand Down
22 changes: 11 additions & 11 deletions frontend/front-srv/assets/uploader.html/i18n/pt-br.all.json
Original file line number Diff line number Diff line change
Expand Up @@ -60,37 +60,37 @@
"other": "Enviando arquivos para o servidor..."
},
"task.status.folders": {
"other": "Creating Folders"
"other": "Criando Pastas"
},
"task.message.folder-one": {
"other": "Creating one folder"
"other": "Criando uma pasta"
},
"task.message.folder-many": {
"other": "Creating %s folders"
"other": "Criando %s pastas"
},
"task.status.analyse": {
"other": "Preparing files for upload"
"other": "Preparando arquivos para envio"
},
"task.message.analyse-many": {
"other": "Analyzing %s items..."
"other": "Analisando %s itens..."
},
"task.message.analyse-one": {
"other": "Analyzing one item"
"other": "Analisando um item"
},
"task.message.analyse-wait": {
"other": "Please wait..."
"other": "Aguarde..."
},
"task.status.ready": {
"other": "Ready to upload"
"other": "Pronto para enviar"
},
"task.status.paused": {
"other": "Upload paused"
"other": "Envio pausado"
},
"task.status.upload": {
"other": "Uploading files"
"other": "Enviando arquivos"
},
"task.message.upload-progress": {
"other": "Uploading %s%"
"other": "Enviando %s%"
},
"no-folders-support": {
"other": "Parece que seu navegador não oferece suporte a descarte de pastas"
Expand Down
8 changes: 8 additions & 0 deletions x/configx/config_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ package configx
import (
"fmt"
"github.com/pydio/cells/x/filex"
"strings"
"testing"

json "github.com/pydio/cells/x/jsonx"
Expand Down Expand Up @@ -289,3 +290,10 @@ func TestScan(t *testing.T) {
So(err, ShouldBeNil)
})
}

func TestDefault(t *testing.T) {
Convey("Testing reference", t, func() {
So(strings.Join(StringToKeys("1/2/#/3"), "/"), ShouldEqual, "#/3")
So(strings.Join(StringToKeys("1/2/#/3/#/4"), "/"), ShouldEqual, "#/4")
})
}
10 changes: 10 additions & 0 deletions x/configx/key.go
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,16 @@ func StringToKeys(s ...string) []string {
r = append(r, strings.Split(v, "/")...)
}

lastIndex := 0
for i, v := range r {
if v == "#" {
lastIndex = i

}
}

r = r[lastIndex:]

return r
}

Expand Down

0 comments on commit cde07cf

Please sign in to comment.