|
|
@ -5,11 +5,10 @@ import ( |
|
|
|
"database/sql" |
|
|
|
"encoding/base64" |
|
|
|
"fmt" |
|
|
|
"strings" |
|
|
|
|
|
|
|
"github.com/chrislusf/seaweedfs/weed/filer" |
|
|
|
"github.com/chrislusf/seaweedfs/weed/glog" |
|
|
|
"github.com/chrislusf/seaweedfs/weed/util" |
|
|
|
"strings" |
|
|
|
) |
|
|
|
|
|
|
|
func (store *AbstractSqlStore) KvPut(ctx context.Context, key []byte, value []byte) (err error) { |
|
|
@ -17,11 +16,13 @@ func (store *AbstractSqlStore) KvPut(ctx context.Context, key []byte, value []by |
|
|
|
dirStr, dirHash, name := genDirAndName(key) |
|
|
|
|
|
|
|
res, err := store.getTxOrDB(ctx).ExecContext(ctx, store.SqlInsert, dirHash, name, dirStr, value) |
|
|
|
if err != nil { |
|
|
|
if err == nil { |
|
|
|
return |
|
|
|
} |
|
|
|
|
|
|
|
if !strings.Contains(strings.ToLower(err.Error()), "duplicate") { |
|
|
|
return fmt.Errorf("kv insert: %s", err) |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
// now the insert failed possibly due to duplication constraints
|
|
|
|
glog.V(1).Infof("kv insert falls back to update: %s", err) |
|
|
|