mirror of
https://github.com/ProtonMail/proton-bridge.git
synced 2025-12-17 23:56:56 +00:00
Other: Factory reset
This commit is contained in:
@ -283,10 +283,6 @@ func (bridge *Bridge) GetEvents(ofType ...events.Event) (<-chan events.Event, fu
|
||||
return newWatcher.GetChannel(), func() { bridge.remWatcher(newWatcher) }
|
||||
}
|
||||
|
||||
func (bridge *Bridge) FactoryReset(ctx context.Context) error {
|
||||
panic("TODO")
|
||||
}
|
||||
|
||||
func (bridge *Bridge) PushError(err error) {
|
||||
bridge.errors = append(bridge.errors, err)
|
||||
}
|
||||
|
||||
@ -8,6 +8,7 @@ import (
|
||||
"github.com/ProtonMail/proton-bridge/v2/internal/updater"
|
||||
"github.com/ProtonMail/proton-bridge/v2/internal/user"
|
||||
"github.com/ProtonMail/proton-bridge/v2/internal/vault"
|
||||
"github.com/sirupsen/logrus"
|
||||
)
|
||||
|
||||
func (bridge *Bridge) GetKeychainApp() (string, error) {
|
||||
@ -238,3 +239,19 @@ func (bridge *Bridge) GetColorScheme() string {
|
||||
func (bridge *Bridge) SetColorScheme(colorScheme string) error {
|
||||
return bridge.vault.SetColorScheme(colorScheme)
|
||||
}
|
||||
|
||||
func (bridge *Bridge) FactoryReset(ctx context.Context) {
|
||||
// First delete all users.
|
||||
for _, userID := range bridge.GetUserIDs() {
|
||||
if bridge.users.Has(userID) {
|
||||
if err := bridge.DeleteUser(ctx, userID); err != nil {
|
||||
logrus.WithError(err).Errorf("Failed to delete user %s", userID)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Then delete all files.
|
||||
if err := bridge.locator.Clear(); err != nil {
|
||||
logrus.WithError(err).Error("Failed to clear data paths")
|
||||
}
|
||||
}
|
||||
|
||||
@ -9,6 +9,7 @@ type Locator interface {
|
||||
ProvideLogsPath() (string, error)
|
||||
GetLicenseFilePath() string
|
||||
GetDependencyLicensesLink() string
|
||||
Clear() error
|
||||
}
|
||||
|
||||
type Identifier interface {
|
||||
|
||||
Reference in New Issue
Block a user