Skip to content

armgit / ente

Public Imported from GitHub
0

πŸ’š End-to-end encrypted cloud for everything.

[cli]fix: add func to check keyring availabilitye

mngshm428900530248
diff --git a/cli/main.go b/cli/main.go
index 8971443894..c9f65cbd89 100644
--- a/cli/main.go
+++ b/cli/main.go
@@ -129,9 +129,11 @@ func GetCLIConfigDir() (string, error) {
// Throw instructoin if none of the environment variables has been set.
if configDir == "" && oldConfigPath == "" {
- fmt.Println(`Environment variable for the config dir is not set. Please setup
+ if !secrets.IsKeyringAvailable() {
+ fmt.Println(`Environment variable for the config dir is not set. Please setup
the environment variable with export ENTE_CLI_CONFIG_DIR="/path/to/config"
`)
+ }
}
if configDir != "" {
// remove trailing slash (for all OS)
diff --git a/cli/pkg/secrets/secret.go b/cli/pkg/secrets/secret.go
index 629604bde3..998c038a69 100644
--- a/cli/pkg/secrets/secret.go
+++ b/cli/pkg/secrets/secret.go
@@ -77,6 +77,16 @@ func GetOrCreateClISecret() []byte {
return legacySecret
}
+// Simple function to check if keyring is available or not
+func IsKeyringAvailable() bool {
+ _, err := keyring.Get(secretService, secretUser)
+
+ if err != nil && !errors.Is(err, keyring.ErrNotFound) {
+ return false
+ }
+ return true
+}
+
// GetSecretFromSecretText reads the scecret from the secret text file.
// If the file does not exist, it will be created and write random keyLength bytes secret to it.
func GetSecretFromSecretText(secretFilePath string) []byte {