diff --git a/modules/nfs-server/cmd/nfs-server/review_test.go b/modules/nfs-server/cmd/nfs-server/review_test.go index 925f36a83..1f35d1385 100644 --- a/modules/nfs-server/cmd/nfs-server/review_test.go +++ b/modules/nfs-server/cmd/nfs-server/review_test.go @@ -508,4 +508,13 @@ func TestARestartKeepsTheExportedShareWhileItsFirstLookRuns(t *testing.T) { if len(held) != 1 || refusedWhy(s, "clean") != "" || f.read(ExportFile) != before || countExportfs(f.ran) != 0 { t.Errorf("a restart with an unfinished walk unexported the share: %+v, ran %v", s.Refused, f.ran) } + // The same name, a new folder holding a repository, the walk unfinished: refused, not carried by name. + f.restic("/srv/other/backup") + f.file(ConfigFile, grantsConfig("clean=/srv/other", "clean=ws:rw")) + m3 := f.machine() + m3.Beside = func(func()) {} + s = m3.Pass(context.Background(), &s) + if refusedWhy(s, "clean") == "" || strings.Contains(f.read(ExportFile), "/srv/other") { + t.Errorf("a share moved to a new folder was exported unlooked: %+v", s.Refused) + } } diff --git a/modules/nfs-server/cmd/nfs-server/shares.go b/modules/nfs-server/cmd/nfs-server/shares.go index 8ef26637d..fab71438c 100644 --- a/modules/nfs-server/cmd/nfs-server/shares.go +++ b/modules/nfs-server/cmd/nfs-server/shares.go @@ -456,7 +456,7 @@ func (m *Machine) Judge(c Config, roster map[string]string, wants map[string][]W no(fmt.Sprintf("The share %s's folder %s%s holds a backup repository (%s), and backups are never exported: share the folders beside it instead.", s.Name, real, via, holds)) continue } - if pending && !carries(onDisk, s.Name, real) { + if pending && !carries(onDisk, real) { no(fmt.Sprintf("The share %s's folder %s%s has not been looked through yet for a backup repository (the look runs beside the pass and takes a while on a large folder), so it is not exported yet.", s.Name, real, via)) continue } @@ -531,12 +531,12 @@ func (m *Machine) Judge(c Config, roster map[string]string, wants map[string][]W return out, refused, said } -// carries says whether the export file already carries a share: its line, or the note that it goes to no -// node. While a share's first look is unfinished (after a restart) it stays as the previous process judged +// carries says whether the export file already holds the line for this real folder (a share exported to no +// node has none and waits for its look; a share whose folder changed is a new folder). While a share's first look is unfinished (after a restart) it stays as the previous process judged // it, so a delivery never unexports a share clients have mounted. -func carries(file, name, real string) bool { +func carries(file, real string) bool { for _, l := range strings.Split(file, "\n") { - if strings.HasPrefix(l, real+" ") || l == "# share "+name || strings.HasPrefix(l, "# share "+name+":") { + if strings.HasPrefix(l, real+" ") { return true } }