Skip to content

Commit 2e419fa

Browse files
committed
Use the new within_path= parameter for listing registered directories.
1 parent a813065 commit 2e419fa

File tree

1 file changed

+4
-7
lines changed

1 file changed

+4
-7
lines changed

register.go

Lines changed: 4 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -71,14 +71,13 @@ func listRegisteredDirectoriesRaw(url string) ([]registeredDirectory, error) {
7171
}
7272

7373
func listRegisteredSubdirectories(rest_url, dir string) ([]string, error) {
74-
prefix := dir + "/"
75-
output, err := listRegisteredDirectoriesRaw(rest_url + "/registered?path_prefix=" + url.QueryEscape(prefix))
74+
output, err := listRegisteredDirectoriesRaw(rest_url + "/registered?within_path=" + url.QueryEscape(dir))
7675
if err != nil {
7776
return nil, fmt.Errorf("failed to list subdirectories of %q; %w", dir, err)
7877
}
7978
collected := []string{}
8079
for _, val := range output {
81-
rel, err := filepath.Rel(prefix, val.Path)
80+
rel, err := filepath.Rel(dir, val.Path)
8281
if err == nil && filepath.IsLocal(rel) {
8382
collected = append(collected, rel)
8483
}
@@ -158,8 +157,7 @@ func registerDirectory(rest_url, dir string, register bool) error {
158157
}
159158

160159
func deregisterAllSubdirectories(rest_url, dir string) error {
161-
prefix := dir + "/"
162-
output, err := listRegisteredDirectoriesRaw(rest_url + "/registered?path_prefix=" + url.QueryEscape(prefix))
160+
output, err := listRegisteredDirectoriesRaw(rest_url + "/registered?within_path=" + url.QueryEscape(dir))
163161
if err != nil {
164162
return fmt.Errorf("failed to list subdirectories of %q; %w", dir, err)
165163
}
@@ -172,8 +170,7 @@ func deregisterAllSubdirectories(rest_url, dir string) error {
172170
}
173171

174172
func deregisterMissingSubdirectories(rest_url, dir string) error {
175-
prefix := dir + "/"
176-
output, err := listRegisteredDirectoriesRaw(rest_url + "/registered?path_prefix=" + url.QueryEscape(prefix) + "&exists=false")
173+
output, err := listRegisteredDirectoriesRaw(rest_url + "/registered?within_path=" + url.QueryEscape(dir) + "&exists=false")
177174
if err != nil {
178175
return fmt.Errorf("failed to list subdirectories of %q; %w", dir, err)
179176
}

0 commit comments

Comments
 (0)