sysupdate: Evaluate all patterns before descending into a subdir
When we have two match patterns, e.g., because the repository layout changed and we look for old and new style files, we can have the case that one pattern suggests a descend into a subdir but the other pattern would be a direct match. This was missed and only the descent was done. Yet the other way round also has to be covered: We can't just use the direct match because it might be that it's rejected if the type doesn't fit (directory vs. regular file). In this case we should still descent. Remember that we want to descend but continue checking the other pattern first to maybe get a direct match. Introduce a new combined return code YES_AND_RETRY to give the full information to the caller which now can decide to fallback to a descent. While at it, use the stat info for the directory check. Also add tests to ensure that the order of patterns doesn't matter and we handle the above corner cases.
This commit is contained in:
@@ -7,6 +7,7 @@ enum {
|
||||
PATTERN_MATCH_NO,
|
||||
PATTERN_MATCH_YES,
|
||||
PATTERN_MATCH_RETRY,
|
||||
PATTERN_MATCH_YES_AND_RETRY,
|
||||
};
|
||||
|
||||
int pattern_match(const char *pattern, const char *s, InstanceMetadata *ret);
|
||||
|
||||
Reference in New Issue
Block a user