mirror of
https://github.com/OpenListTeam/OpenList.git
synced 2025-11-25 03:15:19 +08:00
fix(fs): nil interface not equal to nil (#971)
https://go.dev/doc/faq#nil_error
This commit is contained in:
@@ -371,7 +371,7 @@ func DriverExtract(ctx context.Context, storage driver.Driver, path string, args
|
||||
return link.Link, link.Obj, nil
|
||||
}
|
||||
|
||||
var forget utils.CloseFunc
|
||||
var forget any
|
||||
fn := func() (*extractLink, error) {
|
||||
link, err := driverExtract(ctx, storage, path, args)
|
||||
if err != nil {
|
||||
@@ -380,7 +380,7 @@ func DriverExtract(ctx context.Context, storage driver.Driver, path string, args
|
||||
if link.Link.Expiration != nil {
|
||||
extractCache.Set(key, link, cache.WithEx[*extractLink](*link.Link.Expiration))
|
||||
}
|
||||
link.Add(forget)
|
||||
link.AddIfCloser(forget)
|
||||
return link, nil
|
||||
}
|
||||
|
||||
@@ -392,13 +392,13 @@ func DriverExtract(ctx context.Context, storage driver.Driver, path string, args
|
||||
return link.Link, link.Obj, nil
|
||||
}
|
||||
|
||||
forget = func() error {
|
||||
forget = utils.CloseFunc(func() error {
|
||||
if forget != nil {
|
||||
forget = nil
|
||||
linkG.Forget(key)
|
||||
}
|
||||
return nil
|
||||
}
|
||||
})
|
||||
link, err, _ := extractG.Do(key, fn)
|
||||
if err == nil && !link.AcquireReference() {
|
||||
link, err, _ = extractG.Do(key, fn)
|
||||
|
||||
@@ -291,7 +291,7 @@ func Link(ctx context.Context, storage driver.Driver, path string, args model.Li
|
||||
return link, file, nil
|
||||
}
|
||||
|
||||
var forget utils.CloseFunc
|
||||
var forget any
|
||||
fn := func() (*model.Link, error) {
|
||||
link, err := storage.Link(ctx, file, args)
|
||||
if err != nil {
|
||||
@@ -300,7 +300,7 @@ func Link(ctx context.Context, storage driver.Driver, path string, args model.Li
|
||||
if link.Expiration != nil {
|
||||
linkCache.Set(key, link, cache.WithEx[*model.Link](*link.Expiration))
|
||||
}
|
||||
link.Add(forget)
|
||||
link.AddIfCloser(forget)
|
||||
return link, nil
|
||||
}
|
||||
|
||||
@@ -312,13 +312,13 @@ func Link(ctx context.Context, storage driver.Driver, path string, args model.Li
|
||||
return link, file, err
|
||||
}
|
||||
|
||||
forget = func() error {
|
||||
forget = utils.CloseFunc(func() error {
|
||||
if forget != nil {
|
||||
forget = nil
|
||||
linkG.Forget(key)
|
||||
}
|
||||
return nil
|
||||
}
|
||||
})
|
||||
link, err, _ := linkG.Do(key, fn)
|
||||
if err == nil && !link.AcquireReference() {
|
||||
link, err, _ = linkG.Do(key, fn)
|
||||
|
||||
Reference in New Issue
Block a user