@@ -133,10 +133,10 @@ func (a NotebooksAPI) Mkdirs(path string) error {
133133// List will list all objects in a path on the workspace
134134// and with the recursive flag it will recursively list
135135// all the objects
136- func (a NotebooksAPI ) List (path string , recursive bool ) ([]ObjectStatus , error ) {
136+ func (a NotebooksAPI ) List (path string , recursive bool , ignoreErrors bool ) ([]ObjectStatus , error ) {
137137 if recursive {
138138 var paths []ObjectStatus
139- err := a .recursiveAddPaths (path , & paths )
139+ err := a .recursiveAddPaths (path , & paths , ignoreErrors )
140140 if err != nil {
141141 return nil , err
142142 }
@@ -145,28 +145,28 @@ func (a NotebooksAPI) List(path string, recursive bool) ([]ObjectStatus, error)
145145 return a .list (path )
146146}
147147
148- func (a NotebooksAPI ) recursiveAddPaths (path string , pathList * []ObjectStatus ) error {
148+ func (a NotebooksAPI ) recursiveAddPaths (path string , pathList * []ObjectStatus , ignoreErrors bool ) error {
149149 notebookInfoList , err := a .list (path )
150- if err != nil {
150+ if err != nil && ! ignoreErrors {
151151 return err
152152 }
153153 for _ , v := range notebookInfoList {
154154 if v .ObjectType == Notebook || v .ObjectType == File {
155155 * pathList = append (* pathList , v )
156156 } else if v .ObjectType == Directory {
157- err := a .recursiveAddPaths (v .Path , pathList )
157+ err := a .recursiveAddPaths (v .Path , pathList , ignoreErrors )
158158 if err != nil {
159159 return err
160160 }
161161 }
162162 }
163- return err
163+ return nil
164164}
165165
166- func (a NotebooksAPI ) ListDirectories (path string , recursive bool ) ([]ObjectStatus , error ) {
166+ func (a NotebooksAPI ) ListDirectories (path string , recursive bool , ignoreErrors bool ) ([]ObjectStatus , error ) {
167167 if recursive {
168168 var paths []ObjectStatus
169- err := a .recursiveAddDirectoryPaths (path , & paths )
169+ err := a .recursiveAddDirectoryPaths (path , & paths , ignoreErrors )
170170 if err != nil {
171171 return nil , err
172172 }
@@ -175,21 +175,21 @@ func (a NotebooksAPI) ListDirectories(path string, recursive bool) ([]ObjectStat
175175 return a .list (path )
176176}
177177
178- func (a NotebooksAPI ) recursiveAddDirectoryPaths (path string , pathList * []ObjectStatus ) error {
178+ func (a NotebooksAPI ) recursiveAddDirectoryPaths (path string , pathList * []ObjectStatus , ignoreErrors bool ) error {
179179 directoryInfoList , err := a .list (path )
180- if err != nil {
180+ if err != nil && ! ignoreErrors {
181181 return err
182182 }
183183 for _ , v := range directoryInfoList {
184184 if v .ObjectType == Directory {
185185 * pathList = append (* pathList , v )
186- err := a .recursiveAddDirectoryPaths (v .Path , pathList )
186+ err := a .recursiveAddDirectoryPaths (v .Path , pathList , ignoreErrors )
187187 if err != nil {
188188 return err
189189 }
190190 }
191191 }
192- return err
192+ return nil
193193}
194194
195195type ObjectList struct {
0 commit comments