From c048a71716036ce28a917490220797ba1fdd6521 Mon Sep 17 00:00:00 2001 From: Michael Mayer Date: Wed, 21 Oct 2020 07:39:25 +0200 Subject: [PATCH] Improve comments for MediaFile.RelatedFiles() #560 Signed-off-by: Michael Mayer --- internal/photoprism/mediafile.go | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/internal/photoprism/mediafile.go b/internal/photoprism/mediafile.go index 650006a87..f2853e3e9 100644 --- a/internal/photoprism/mediafile.go +++ b/internal/photoprism/mediafile.go @@ -283,15 +283,17 @@ func (m *MediaFile) JsonName() string { // RelatedFiles returns files which are related to this file. func (m *MediaFile) RelatedFiles(stripSequence bool) (result RelatedFiles, err error) { - // escape any meta characters in the file name var prefix string if stripSequence { + // Strip common name sequences like "copy 2" and escape meta characters. prefix = regexp.QuoteMeta(m.AbsPrefix(true)) } else { + // Use strict file name matching and escape meta characters. prefix = regexp.QuoteMeta(m.AbsPrefix(false) + ".") } + // Find related files. matches, err := filepath.Glob(prefix + "*") if err != nil {