Skip to content

Commit

Permalink
fix: incorrect persistence storage path
Browse files Browse the repository at this point in the history
  • Loading branch information
Yeuoly committed Nov 8, 2024
1 parent 7a24210 commit aec7ef0
Show file tree
Hide file tree
Showing 8 changed files with 23 additions and 74 deletions.
2 changes: 1 addition & 1 deletion .env.example
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ PLUGIN_WORKING_PATH=./cwd

# persistence storage
PERSISTENCE_STORAGE_TYPE=local
PERSISTENCE_STORAGE_LOCAL_PATH=./persistence
PERSISTENCE_STORAGE_PATH=./persistence
PERSISTENCE_STORAGE_MAX_SIZE=104857600

# plugin webhook
Expand Down
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -10,3 +10,4 @@ __pycache__
media-cache
subprocesses
working
cwd/
2 changes: 1 addition & 1 deletion internal/core/persistence/init.go
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ var (

func InitPersistence(oss oss.OSS, config *app.Config) {
persistence = &Persistence{
storage: NewWrapper(oss),
storage: NewWrapper(oss, config.PersistenceStoragePath),
max_storage_size: config.PersistenceStorageMaxSize,
}

Expand Down
55 changes: 0 additions & 55 deletions internal/core/persistence/local.go

This file was deleted.

12 changes: 6 additions & 6 deletions internal/core/persistence/persistence_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -31,8 +31,8 @@ func TestPersistenceStoreAndLoad(t *testing.T) {
oss := local.NewLocalStorage("./storage")

InitPersistence(oss, &app.Config{
PersistenceStorageLocalPath: "./persistence_storage",
PersistenceStorageMaxSize: 1024 * 1024 * 1024,
PersistenceStoragePath: "./persistence_storage",
PersistenceStorageMaxSize: 1024 * 1024 * 1024,
})

key := strings.RandomString(10)
Expand Down Expand Up @@ -88,8 +88,8 @@ func TestPersistenceSaveAndLoadWithLongKey(t *testing.T) {
defer db.Close()

InitPersistence(local.NewLocalStorage("./storage"), &app.Config{
PersistenceStorageLocalPath: "./persistence_storage",
PersistenceStorageMaxSize: 1024 * 1024 * 1024,
PersistenceStoragePath: "./persistence_storage",
PersistenceStorageMaxSize: 1024 * 1024 * 1024,
})

key := strings.RandomString(65)
Expand Down Expand Up @@ -118,8 +118,8 @@ func TestPersistenceDelete(t *testing.T) {
oss := local.NewLocalStorage("./storage")

InitPersistence(oss, &app.Config{
PersistenceStorageLocalPath: "./persistence_storage",
PersistenceStorageMaxSize: 1024 * 1024 * 1024,
PersistenceStoragePath: "./persistence_storage",
PersistenceStorageMaxSize: 1024 * 1024 * 1024,
})

key := strings.RandomString(10)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,17 +7,19 @@ import (
)

type wrapper struct {
oss oss.OSS
oss oss.OSS
persistence_storage_path string
}

func NewWrapper(oss oss.OSS) *wrapper {
func NewWrapper(oss oss.OSS, persistence_storage_path string) *wrapper {
return &wrapper{
oss: oss,
oss: oss,
persistence_storage_path: persistence_storage_path,
}
}

func (s *wrapper) getFilePath(tenant_id string, plugin_checksum string, key string) string {
return path.Join(tenant_id, plugin_checksum, key)
return path.Join(s.persistence_storage_path, tenant_id, plugin_checksum, key)
}

func (s *wrapper) Save(tenant_id string, plugin_checksum string, key string, data []byte) error {
Expand Down
4 changes: 2 additions & 2 deletions internal/types/app/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -63,8 +63,8 @@ type Config struct {
DBSslMode string `envconfig:"DB_SSL_MODE" validate:"required,oneof=disable require"`

// persistence storage
PersistenceStorageLocalPath string `envconfig:"PERSISTENCE_STORAGE_LOCAL_PATH"`
PersistenceStorageMaxSize int64 `envconfig:"PERSISTENCE_STORAGE_MAX_SIZE"`
PersistenceStoragePath string `envconfig:"PERSISTENCE_STORAGE_PATH"`
PersistenceStorageMaxSize int64 `envconfig:"PERSISTENCE_STORAGE_MAX_SIZE"`

// force verifying signature for all plugins, not allowing install plugin not signed
ForceVerifyingSignature bool `envconfig:"FORCE_VERIFYING_SIGNATURE"`
Expand Down
11 changes: 6 additions & 5 deletions internal/types/app/default.go
Original file line number Diff line number Diff line change
Expand Up @@ -20,12 +20,13 @@ func (config *Config) SetDefault() {
setDefaultBool(&config.PluginRemoteInstallingEnabled, true)
setDefaultBool(&config.PluginEndpointEnabled, true)
setDefaultString(&config.DBSslMode, "disable")
setDefaultString(&config.PluginInstalledPath, "./storage/plugin")
setDefaultString(&config.PluginMediaCachePath, "./storage/assets")
setDefaultString(&config.PersistenceStorageLocalPath, "./storage/persistence")
setDefaultString(&config.PluginStorageLocalRoot, "./storage")
setDefaultString(&config.PluginInstalledPath, "./plugin")
setDefaultString(&config.PluginMediaCachePath, "./assets")
setDefaultString(&config.PersistenceStoragePath, "./persistence")
setDefaultInt(&config.PersistenceStorageMaxSize, 100*1024*1024)
setDefaultString(&config.ProcessCachingPath, "./storage/subprocesses")
setDefaultString(&config.PluginPackageCachePath, "./storage/plugin_packages")
setDefaultString(&config.ProcessCachingPath, "./subprocesses")
setDefaultString(&config.PluginPackageCachePath, "./plugin_packages")
setDefaultString(&config.PythonInterpreterPath, "/usr/bin/python3")
}

Expand Down

0 comments on commit aec7ef0

Please sign in to comment.