Browse Source

fix test_bucket_listv2_continuationtoken

pull/5580/head
Konstantin Lebedev 8 months ago
parent
commit
7ddb99645f
  1. 2
      weed/filer/abstract_sql/abstract_sql_store.go
  2. 2
      weed/filer/mysql/mysql_sql_gen.go
  3. 14
      weed/s3api/s3api_object_handlers_list.go

2
weed/filer/abstract_sql/abstract_sql_store.go

@ -366,7 +366,7 @@ func (store *AbstractSqlStore) ListRecursivePrefixedEntries(ctx context.Context,
} else { } else {
fileName = dir + name fileName = dir + name
} }
lastFileName = fmt.Sprintf("%s/%s", dir, name)
lastFileName = fmt.Sprintf("%s%s", dir, name)
entry := &filer.Entry{ entry := &filer.Entry{
FullPath: util.NewFullPath(bucketDir, fileName), FullPath: util.NewFullPath(bucketDir, fileName),
} }

2
weed/filer/mysql/mysql_sql_gen.go

@ -50,7 +50,7 @@ func (gen *SqlGenMysql) GetSqlListInclusive(tableName string) string {
} }
func (gen *SqlGenMysql) GetSqlListRecursive(tableName string) string { func (gen *SqlGenMysql) GetSqlListRecursive(tableName string) string {
return fmt.Sprintf("SELECT `directory`, `name`, `meta` FROM `%s` WHERE `directory` || '/' || `name` > ? AND ((`dirhash` == ? AND `name` like ?) OR `directory` like ?) ORDER BY `directory` || '/' || `name` ASC LIMIT ?", tableName)
return fmt.Sprintf("SELECT `directory`, `name`, `meta` FROM `%s` WHERE `directory` || `name` > ? AND ((`dirhash` == ? AND `name` like ?) OR `directory` like ?) ORDER BY `directory` || `name` ASC LIMIT ?", tableName)
} }
func (gen *SqlGenMysql) GetSqlCreateTable(tableName string) string { func (gen *SqlGenMysql) GetSqlCreateTable(tableName string) string {

14
weed/s3api/s3api_object_handlers_list.go

@ -155,12 +155,12 @@ func (s3a *S3ApiServer) listFilerEntries(bucket string, originalPrefix string, m
reqDir += originalPrefix[:idx] reqDir += originalPrefix[:idx]
prefix = originalPrefix[idx+1:] prefix = originalPrefix[idx+1:]
} }
// This is necessary for SQL request with WHERE `directory` || '/' || `name` > originalMarker
// This is necessary for SQL request with WHERE `directory` || `name` > originalMarker
if len(originalMarker) > 0 && originalMarker[0:1] != "/" { if len(originalMarker) > 0 && originalMarker[0:1] != "/" {
if reqDir == bucketPrefix {
marker = "//" + originalMarker
} else {
if idx := strings.LastIndex(originalMarker, "/"); idx == -1 {
marker = "/" + originalMarker marker = "/" + originalMarker
} else {
marker = fmt.Sprintf("/%s%s", originalMarker[0:idx], originalMarker[idx+1:len(originalMarker)])
} }
} else { } else {
marker = originalMarker marker = originalMarker
@ -192,10 +192,10 @@ func (s3a *S3ApiServer) listFilerEntries(bucket string, originalPrefix string, m
defer func() { defer func() {
if cursor.maxKeys == 0 { if cursor.maxKeys == 0 {
cursor.isTruncated = true cursor.isTruncated = true
if strings.Index(key, "/") == -1 {
cursor.nextMarker = "//" + key
} else {
if idx := strings.Index(key, "/"); idx == -1 {
cursor.nextMarker = "/" + key cursor.nextMarker = "/" + key
} else {
cursor.nextMarker = fmt.Sprintf("/%s%s", key[0:idx], key[idx+1:len(key)])
} }
} }
}() }()

Loading…
Cancel
Save