@@ -111,10 +111,7 @@ func (h Pass) Delete(serverURL string) error {
111
111
return err
112
112
}
113
113
114
- // listPassDir lists all the contents of a directory in the password store.
115
- // Pass uses fancy unicode to emit stuff to stdout, so rather than try
116
- // and parse this, let's just look at the directory structure instead.
117
- func listPassDir (args ... string ) ([]os.FileInfo , error ) {
114
+ func getPassDir () string {
118
115
passDir := os .ExpandEnv ("$HOME/.password-store" )
119
116
for _ , e := range os .Environ () {
120
117
parts := strings .SplitN (e , "=" , 2 )
@@ -130,6 +127,14 @@ func listPassDir(args ...string) ([]os.FileInfo, error) {
130
127
break
131
128
}
132
129
130
+ return passDir
131
+ }
132
+
133
+ // listPassDir lists all the contents of a directory in the password store.
134
+ // Pass uses fancy unicode to emit stuff to stdout, so rather than try
135
+ // and parse this, let's just look at the directory structure instead.
136
+ func listPassDir (args ... string ) ([]os.FileInfo , error ) {
137
+ passDir := getPassDir ()
133
138
p := path .Join (append ([]string {passDir , PASS_FOLDER }, args ... )... )
134
139
contents , err := ioutil .ReadDir (p )
135
140
if err != nil {
@@ -155,6 +160,14 @@ func (h Pass) Get(serverURL string) (string, string, error) {
155
160
156
161
encoded := base64 .URLEncoding .EncodeToString ([]byte (serverURL ))
157
162
163
+ if _ , err := os .Stat (path .Join (getPassDir (), PASS_FOLDER , encoded )); err != nil {
164
+ if os .IsNotExist (err ) {
165
+ return "" , "" , nil ;
166
+ }
167
+
168
+ return "" , "" , err
169
+ }
170
+
158
171
usernames , err := listPassDir (encoded )
159
172
if err != nil {
160
173
return "" , "" , err
0 commit comments