Skip to content

Commit 862f48a

Browse files
committed
update isDirTarget to only consider literal '/' suffix for GCS directories
1 parent d503336 commit 862f48a

File tree

2 files changed

+8
-10
lines changed

2 files changed

+8
-10
lines changed

plugin.go

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -306,11 +306,10 @@ func (p *Plugin) isFileOnDisk(path string) bool {
306306
return err == nil && !info.IsDir()
307307
}
308308

309-
// isDirTarget determines if the target should be treated as a directory
310-
// Returns true if target ends with / or has no file extension
309+
// isDirTarget determines if the target should be treated as a directory.
310+
// On GCS we only care about a literal '/' suffix.
311311
func (p *Plugin) isDirTarget(target string) bool {
312-
target = filepath.Clean(target)
313-
return strings.HasSuffix(target, "/") || filepath.Ext(target) == ""
312+
return strings.HasSuffix(target, "/")
314313
}
315314

316315
// isAbsolutePath checks if a path is absolute on any platform (Unix or Windows)

plugin_test.go

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -492,11 +492,11 @@ func TestTargetPathFix(t *testing.T) {
492492
}
493493

494494
func TestCrossPlatformPaths(t *testing.T) {
495-
495+
496496
// Test that filepath.IsAbs is used correctly for different platforms
497497
tests := []struct {
498-
name string
499-
path string
498+
name string
499+
path string
500500
wantAbs bool
501501
}{
502502
{"Unix absolute", "/home/user/file.txt", true},
@@ -529,8 +529,8 @@ func TestHelperFunctions(t *testing.T) {
529529
t.Error("path ending with slash should be directory")
530530
}
531531

532-
if !plugin.isDirTarget("uploads") {
533-
t.Error("path without extension should be directory")
532+
if plugin.isDirTarget("uploads") {
533+
t.Error("path without slash should be file")
534534
}
535535

536536
if plugin.isDirTarget("file.zip") {
@@ -540,7 +540,6 @@ func TestHelperFunctions(t *testing.T) {
540540

541541
// TestShouldIgnoreFile tests ignore pattern functionality
542542
func TestShouldIgnoreFile(t *testing.T) {
543-
// ... (rest of the code remains the same)
544543
tests := []struct {
545544
name string
546545
ignorePattern string

0 commit comments

Comments
 (0)