mirror of
https://github.com/bbernhard/signal-cli-rest-api.git
synced 2026-05-20 13:44:17 +00:00
handle non existent attachments folder gracefully
This commit is contained in:
parent
3140a56b70
commit
e452205c38
@ -1334,15 +1334,23 @@ func (s *SignalClient) GetAccounts() ([]string, error) {
|
|||||||
func (s *SignalClient) GetAttachments() ([]string, error) {
|
func (s *SignalClient) GetAttachments() ([]string, error) {
|
||||||
files := []string{}
|
files := []string{}
|
||||||
|
|
||||||
err := filepath.Walk(s.signalCliConfig+"/attachments/", func(path string, info os.FileInfo, err error) error {
|
attachmentsPath := s.signalCliConfig+"/attachments/"
|
||||||
if info.IsDir() {
|
if _, err := os.Stat(attachmentsPath); !os.IsNotExist(err) {
|
||||||
|
err = filepath.Walk(attachmentsPath, func(path string, info os.FileInfo, err error) error {
|
||||||
|
if info.IsDir() {
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
files = append(files, filepath.Base(path))
|
||||||
return nil
|
return nil
|
||||||
|
})
|
||||||
|
if err != nil {
|
||||||
|
return files, err
|
||||||
}
|
}
|
||||||
files = append(files, filepath.Base(path))
|
} else {
|
||||||
return nil
|
return files, nil
|
||||||
})
|
}
|
||||||
|
|
||||||
return files, err
|
return files, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func (s *SignalClient) RemoveAttachment(attachment string) error {
|
func (s *SignalClient) RemoveAttachment(attachment string) error {
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user