diff --git a/README.md b/README.md index 96d85907..c6903c55 100644 --- a/README.md +++ b/README.md @@ -81,12 +81,12 @@ There are now three types of system folders which Bridge recognises: |-----------------------|----------|----------------------------| | bridge lock file | cache | bridge.lock | | bridge-gui lock file | cache | bridge-gui.lock | -| gluon messages | cache | gluon/backend/store | | vault | config | vault.enc | | gRPC server json | config | grpcServerConfig.json | | gRPC client json | config | grpcClientConfig_.json | | Logs | data | logs | | gluon DB | data | gluon/backend/db | +| gluon messages | sata | gluon/backend/store | | Update files | data | updates | | sentry cache | data | sentry_cache | | Mac/Linux File Socket | temp | bridge_{RANDOM_UUID}.sock | diff --git a/go.sum b/go.sum index a5bb1547..fc239f74 100644 --- a/go.sum +++ b/go.sum @@ -28,8 +28,6 @@ github.com/ProtonMail/bcrypt v0.0.0-20211005172633-e235017c1baf h1:yc9daCCYUefEs github.com/ProtonMail/bcrypt v0.0.0-20211005172633-e235017c1baf/go.mod h1:o0ESU9p83twszAU8LBeJKFAAMX14tISa0yk4Oo5TOqo= github.com/ProtonMail/docker-credential-helpers v1.1.0 h1:+kvUIpwWcbtP3WFv5sSvkFn/XLzSqPOB5AAthuk9xPk= github.com/ProtonMail/docker-credential-helpers v1.1.0/go.mod h1:mK0aBveCxhnQ756AmaTfXMZDeULvheYVhF/MWMErN5g= -github.com/ProtonMail/gluon v0.14.2-0.20230118120413-542c2bf244a0 h1:T9wtn35Mqy4Mkr707iECwqo+FhbTVOI9PlRozR5wCO8= -github.com/ProtonMail/gluon v0.14.2-0.20230118120413-542c2bf244a0/go.mod h1:z2AxLIiBCT1K+0OBHyaDI7AEaO5qI6/BEC2TE42vs4Q= github.com/ProtonMail/gluon v0.14.2-0.20230123154940-b7793a0c0bd4 h1:AkRcjX1iArf8fVL4vZd6eaBjE3+SFnwZQKsH3OMyExU= github.com/ProtonMail/gluon v0.14.2-0.20230123154940-b7793a0c0bd4/go.mod h1:z2AxLIiBCT1K+0OBHyaDI7AEaO5qI6/BEC2TE42vs4Q= github.com/ProtonMail/go-autostart v0.0.0-20210130080809-00ed301c8e9a h1:D+aZah+k14Gn6kmL7eKxoo/4Dr/lK3ChBcwce2+SQP4= @@ -43,8 +41,6 @@ github.com/ProtonMail/go-message v0.0.0-20210611055058-fabeff2ec753/go.mod h1:NB github.com/ProtonMail/go-mime v0.0.0-20220302105931-303f85f7fe0f/go.mod h1:NYt+V3/4rEeDuaev/zw1zCq8uqVEuPHzDPo3OZrlGJ4= github.com/ProtonMail/go-mime v0.0.0-20220429130430-2192574d760f h1:4IWzKjHzZxdrW9k4zl/qCwenOVHDbVDADPPHFLjs0Oc= github.com/ProtonMail/go-mime v0.0.0-20220429130430-2192574d760f/go.mod h1:qRZgbeASl2a9OwmsV85aWwRqic0NHPh+9ewGAzb4cgM= -github.com/ProtonMail/go-proton-api v0.3.0 h1:0lRWSp4bGSwWcpVFWMk++z11ZzRHhXAC9k5L6BQ4KQA= -github.com/ProtonMail/go-proton-api v0.3.0/go.mod h1:JUo5IQG0hNuPRuDpOUsCOvtee6UjTEHHF1QN2i8RSos= github.com/ProtonMail/go-proton-api v0.3.1-0.20230118091111-93ad9245e8ee h1:kXz09BKBbVLyzXgHztxIAMuvmSF0g8FgGpDaqi2IPiM= github.com/ProtonMail/go-proton-api v0.3.1-0.20230118091111-93ad9245e8ee/go.mod h1:JUo5IQG0hNuPRuDpOUsCOvtee6UjTEHHF1QN2i8RSos= github.com/ProtonMail/go-rfc5322 v0.11.0 h1:o5Obrm4DpmQEffvgsVqG6S4BKwC1Wat+hYwjIp2YcCY= diff --git a/internal/bridge/bridge.go b/internal/bridge/bridge.go index 396e68f1..9387320e 100644 --- a/internal/bridge/bridge.go +++ b/internal/bridge/bridge.go @@ -221,14 +221,14 @@ func newBridge( return nil, fmt.Errorf("failed to get Gluon directory: %w", err) } - gluonConfigDir, err := locator.ProvideGluonConfigPath() + gluonDataDir, err := locator.ProvideGluonDataPath() if err != nil { return nil, fmt.Errorf("failed to get Gluon Database directory: %w", err) } imapServer, err := newIMAPServer( gluonCacheDir, - gluonConfigDir, + gluonDataDir, curVersion, tlsConfig, reporter, diff --git a/internal/bridge/bridge_test.go b/internal/bridge/bridge_test.go index 5a099279..298a7d66 100644 --- a/internal/bridge/bridge_test.go +++ b/internal/bridge/bridge_test.go @@ -385,7 +385,7 @@ func TestBridge_MissingGluonDatabase(t *testing.T) { require.NoError(t, err) // Get the gluon dir. - gluonDir, err = bridge.GetGluonConfigDir() + gluonDir, err = bridge.GetGluonDataDir() require.NoError(t, err) }) @@ -484,7 +484,7 @@ func TestBridge_FactoryReset(t *testing.T) { func TestBridge_InitGluonDirectory(t *testing.T) { withEnv(t, func(ctx context.Context, s *server.Server, netCtl *proton.NetCtl, locator bridge.Locator, vaultKey []byte) { withBridge(ctx, t, s.GetHostURL(), netCtl, locator, vaultKey, func(b *bridge.Bridge, mocks *bridge.Mocks) { - configDir, err := b.GetGluonConfigDir() + configDir, err := b.GetGluonDataDir() require.NoError(t, err) _, err = os.ReadDir(bridge.ApplyGluonCachePathSuffix(b.GetGluonCacheDir())) @@ -511,7 +511,7 @@ func TestBridge_ChangeCacheDirectory(t *testing.T) { withBridge(ctx, t, s.GetHostURL(), netCtl, locator, vaultKey, func(b *bridge.Bridge, mocks *bridge.Mocks) { newCacheDir := t.TempDir() currentCacheDir := b.GetGluonCacheDir() - configDir, err := b.GetGluonConfigDir() + configDir, err := b.GetGluonDataDir() require.NoError(t, err) // Login the user. diff --git a/internal/bridge/settings.go b/internal/bridge/settings.go index dd274636..198aa1b8 100644 --- a/internal/bridge/settings.go +++ b/internal/bridge/settings.go @@ -119,8 +119,8 @@ func (bridge *Bridge) GetGluonCacheDir() string { return bridge.vault.GetGluonCacheDir() } -func (bridge *Bridge) GetGluonConfigDir() (string, error) { - return bridge.locator.ProvideGluonConfigPath() +func (bridge *Bridge) GetGluonDataDir() (string, error) { + return bridge.locator.ProvideGluonDataPath() } func (bridge *Bridge) SetGluonDir(ctx context.Context, newGluonDir string) error { @@ -148,14 +148,14 @@ func (bridge *Bridge) SetGluonDir(ctx context.Context, newGluonDir string) error } } - gluonDBDir, err := bridge.GetGluonConfigDir() + gluonDataDir, err := bridge.GetGluonDataDir() if err != nil { panic(fmt.Errorf("failed to get Gluon Database directory: %w", err)) } imapServer, err := newIMAPServer( bridge.vault.GetGluonCacheDir(), - gluonDBDir, + gluonDataDir, bridge.curVersion, bridge.tlsConfig, bridge.reporter, diff --git a/internal/bridge/types.go b/internal/bridge/types.go index 2250fd38..4c79defc 100644 --- a/internal/bridge/types.go +++ b/internal/bridge/types.go @@ -27,7 +27,7 @@ type Locator interface { ProvideSettingsPath() (string, error) ProvideLogsPath() (string, error) ProvideGluonCachePath() (string, error) - ProvideGluonConfigPath() (string, error) + ProvideGluonDataPath() (string, error) GetLicenseFilePath() string GetDependencyLicensesLink() string Clear() error diff --git a/internal/locations/locations.go b/internal/locations/locations.go index 97d26bad..197549a4 100644 --- a/internal/locations/locations.go +++ b/internal/locations/locations.go @@ -138,17 +138,7 @@ func (l *Locations) ProvideSettingsPath() (string, error) { return l.getSettingsPath(), nil } -// ProvideGluonConfigPath returns a location for gluon data. -// It creates it if it doesn't already exist. -func (l *Locations) ProvideGluonConfigPath() (string, error) { - if err := os.MkdirAll(l.getGluonConfigPath(), 0o700); err != nil { - return "", err - } - - return l.getGluonConfigPath(), nil -} - -// ProvideGluonCachePath returns a location for gluon message cache data (does not need to be persistent). +// ProvideGluonCachePath returns a location for gluon data. // It creates it if it doesn't already exist. func (l *Locations) ProvideGluonCachePath() (string, error) { if err := os.MkdirAll(l.getGluonCachePath(), 0o700); err != nil { @@ -158,6 +148,16 @@ func (l *Locations) ProvideGluonCachePath() (string, error) { return l.getGluonCachePath(), nil } +// ProvideGluonDataPath returns a location for gluon data. +// It creates it if it doesn't already exist. +func (l *Locations) ProvideGluonDataPath() (string, error) { + if err := os.MkdirAll(l.getGluonDataPath(), 0o700); err != nil { + return "", err + } + + return l.getGluonDataPath(), nil +} + // ProvideLogsPath returns a location for user logs (e.g. ~/.local/share///logs). // It creates it if it doesn't already exist. func (l *Locations) ProvideLogsPath() (string, error) { @@ -189,10 +189,10 @@ func (l *Locations) ProvideUpdatesPath() (string, error) { } func (l *Locations) getGluonCachePath() string { - return filepath.Join(l.userCache, "gluon") + return filepath.Join(l.userData, "gluon") } -func (l *Locations) getGluonConfigPath() string { +func (l *Locations) getGluonDataPath() string { return filepath.Join(l.userData, "gluon") } diff --git a/tests/bridge_test.go b/tests/bridge_test.go index dda24012..9e57773a 100644 --- a/tests/bridge_test.go +++ b/tests/bridge_test.go @@ -88,28 +88,21 @@ func (s *scenario) theUserChangesTheGluonPath() error { } func (s *scenario) theUserDeletesTheGluonFiles() error { - if path, err := s.t.locator.ProvideGluonCachePath(); err != nil { - return fmt.Errorf("failed to get gluon cache path: %w", err) + if path, err := s.t.locator.ProvideGluonDataPath(); err != nil { + return fmt.Errorf("failed to get gluon Data path: %w", err) } else if err := os.RemoveAll(path); err != nil { - return fmt.Errorf("failed to remove gluon cache path: %w", err) + return fmt.Errorf("failed to remove gluon Data path: %w", err) } - if path, err := s.t.locator.ProvideGluonConfigPath(); err != nil { - return fmt.Errorf("failed to get gluon config path: %w", err) - } else if err := os.RemoveAll(path); err != nil { - return fmt.Errorf("failed to remove gluon config path: %w", err) - } - - return nil + return s.theUserDeletesTheGluonCache() } func (s *scenario) theUserDeletesTheGluonCache() error { - if path, err := s.t.locator.ProvideGluonCachePath(); err != nil { - return fmt.Errorf("failed to get gluon cache path: %w", err) + if path, err := s.t.locator.ProvideGluonDataPath(); err != nil { + return fmt.Errorf("failed to get gluon Cache path: %w", err) } else if err := os.RemoveAll(path); err != nil { - return fmt.Errorf("failed to remove gluon cache path: %w", err) + return fmt.Errorf("failed to remove gluon Cache path: %w", err) } - return nil } diff --git a/tests/ctx_bridge_test.go b/tests/ctx_bridge_test.go index 8f89cc4b..fb43cd60 100644 --- a/tests/ctx_bridge_test.go +++ b/tests/ctx_bridge_test.go @@ -100,7 +100,7 @@ func (t *testCtx) initBridge() (<-chan events.Event, error) { } // Get the default gluon path. - gluonCacheDir, err := t.locator.ProvideGluonCachePath() + gluonCacheDir, err := t.locator.ProvideGluonDataPath() if err != nil { return nil, fmt.Errorf("could not get gluon dir: %w", err) }