yandex: correct error return for listing empty directory

This commit is contained in:
Nick Craig-Wood 2017-04-26 18:16:59 +01:00
parent 7e20e16cff
commit fded4dbea2

View file

@ -187,6 +187,10 @@ func (f *Fs) listDir(dir string, fn listFn) (err error) {
for {
ResourceInfoResponse, err := f.yd.NewResourceInfoRequest(root, opt).Exec()
if err != nil {
yErr, ok := err.(yandex.DiskClientError)
if ok && yErr.Code == "DiskNotFoundError" {
return fs.ErrorDirNotFound
}
return err
}
itemsCount = uint32(len(ResourceInfoResponse.Embedded.Items))
@ -246,6 +250,10 @@ func (f *Fs) list(dir string, fn listFn) error {
//send request
info, err := f.yd.NewFlatFileListRequest(opt).Exec()
if err != nil {
yErr, ok := err.(yandex.DiskClientError)
if ok && yErr.Code == "DiskNotFoundError" {
return fs.ErrorDirNotFound
}
return err
}
itemsCount = uint32(len(info.Items))