Skip to content

Commit 0dbdc6e

Browse files
author
TP Honey
authored
Merge pull request #115 from raghavharness/s3_dir_log
Added warn log if only directory is present among the matches of the …
2 parents 094a359 + fd17dd9 commit 0dbdc6e

File tree

1 file changed

+22
-7
lines changed

1 file changed

+22
-7
lines changed

plugin.go

Lines changed: 22 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -148,14 +148,8 @@ func (p *Plugin) Exec() error {
148148
}
149149

150150
for _, match := range matches {
151-
152-
stat, err := os.Stat(match)
153-
if err != nil {
154-
continue // should never happen
155-
}
156-
157151
// skip directories
158-
if stat.IsDir() {
152+
if isDir(match, matches) {
159153
continue
160154
}
161155

@@ -317,3 +311,24 @@ func resolveKey(target, srcPath, stripPrefix string) string {
317311
}
318312
return key
319313
}
314+
315+
// checks if the source path is a dir
316+
func isDir(source string, matches []string) bool {
317+
stat, err := os.Stat(source)
318+
if err != nil {
319+
return true // should never happen
320+
}
321+
if (stat.IsDir()) {
322+
count := 0
323+
for _, match := range matches {
324+
if strings.HasPrefix(match, source) {
325+
count++;
326+
}
327+
}
328+
if count <= 1 {
329+
log.Warnf("Skipping '%s' since it is a directory. Please use correct glob expression if this is unexpected.", source)
330+
}
331+
return true;
332+
}
333+
return false
334+
}

0 commit comments

Comments
 (0)