func mergeRuntimeFiles()

in plugins/internal/discovery/device.go [64:85]


func mergeRuntimeFiles(files []*RuntimeFile, additions []*RuntimeFile) ([]*RuntimeFile, []*RuntimeFile) {
	merged := files
	ignored := []*RuntimeFile{}

	// Add each additional file to the list if it doesn't clash with an existing destination filename
outer:
	for _, additionalFile := range additions {

		// Determine whether we have an existing file with the same destination as the new file
		for _, existingFile := range merged {
			if existingFile.DestinationFilename == additionalFile.DestinationFilename {
				ignored = append(ignored, additionalFile)
				continue outer
			}
		}

		// Add the file to the list
		merged = append(merged, additionalFile)
	}

	return merged, ignored
}