Improve comments for MediaFile.RelatedFiles() #560

Signed-off-by: Michael Mayer <michael@lastzero.net>
This commit is contained in:
Michael Mayer 2020-10-21 07:39:25 +02:00
parent 28ec2df70f
commit c048a71716

View file

@ -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 {