mirror of
https://github.com/langgenius/dify-cloud-kit.git
synced 2026-07-01 20:04:03 -04:00
fix(gcs): List returns relative path instead of full path (#20)
The GCS List method was returning full paths (attrs.Name) instead of relative paths (key with prefix stripped). This was inconsistent with other storage implementations (S3, Local, Azure, Aliyun, Tencent, Huawei, Volcengine) which all return relative paths. The original implementation in dify-plugin-daemon PR #237 correctly used `key`: https://github.com/langgenius/dify-plugin-daemon/pull/237/files#diff-1efde200d0fa3fafdd827478fdbca6e8b16dee52955cb3c93faab2849f7d95bfR136 This bug was introduced when the code was ported to dify-cloud-kit. Also added a test assertion to verify that List returns relative paths. Co-authored-by: Claude Opus 4.5 <noreply@anthropic.com>
This commit is contained in:
+1
-1
@@ -125,7 +125,7 @@ func (g *GoogleCloudStorage) List(prefix string) ([]oss.OSSPath, error) {
|
||||
key = strings.TrimPrefix(key, "/")
|
||||
|
||||
res = append(res, oss.OSSPath{
|
||||
Path: attrs.Name,
|
||||
Path: key,
|
||||
IsDir: false,
|
||||
})
|
||||
|
||||
|
||||
@@ -174,6 +174,9 @@ func TestAll(t *testing.T) {
|
||||
ossPaths, err = storage.List(prefix)
|
||||
assert.Equal(t, 1, len(ossPaths), info)
|
||||
assert.Nil(t, err, info)
|
||||
// Verify that List returns relative paths (without prefix)
|
||||
expectedRelativePath := key[len(prefix)+1:] // +1 for the "/" separator
|
||||
assert.Equal(t, expectedRelativePath, ossPaths[0].Path, info+" - List should return relative path")
|
||||
|
||||
err = storage.Delete(key)
|
||||
assert.Nil(t, err, info)
|
||||
|
||||
Reference in New Issue
Block a user