Исправление "двоения" ErrNotFound
This commit is contained in:
@@ -191,7 +191,7 @@ func (data *SnapshotManagerData) DeleteSnapshot(ctx context.Context, snapshotID
|
||||
|
||||
snapshot, err := data.metadataStore.GetSnapshotMetadata(ctx, snapshotID)
|
||||
if err != nil {
|
||||
if errors.Is(err, store.ErrNotFound) {
|
||||
if errors.Is(err, ErrNotFound) {
|
||||
return nil
|
||||
}
|
||||
return fmt.Errorf("failed to check if snapshot exists: %w", err)
|
||||
@@ -388,7 +388,7 @@ func (data *SnapshotManagerData) UpdateSnapshotMetadata(ctx context.Context, sna
|
||||
|
||||
snapshot, err := data.metadataStore.GetSnapshotMetadata(ctx, snapshotID)
|
||||
if err != nil {
|
||||
if errors.Is(err, store.ErrNotFound) {
|
||||
if errors.Is(err, ErrNotFound) {
|
||||
return ErrNotFound
|
||||
}
|
||||
return fmt.Errorf("failed to get snapshot metadata: %w", err)
|
||||
|
||||
@@ -1,9 +0,0 @@
|
||||
package store
|
||||
|
||||
import "errors"
|
||||
|
||||
// Common errors that can be used by store implementations
|
||||
var (
|
||||
// ErrNotFound means that a requested resource was not found
|
||||
ErrNotFound = errors.New("resource not found")
|
||||
)
|
||||
@@ -7,6 +7,7 @@ import (
|
||||
"os"
|
||||
"path/filepath"
|
||||
|
||||
agate "gitea.unprism.ru/KRBL/Agate"
|
||||
"gitea.unprism.ru/KRBL/Agate/store"
|
||||
)
|
||||
|
||||
@@ -75,7 +76,7 @@ func (fs *fileSystemStore) RetrieveBlob(ctx context.Context, snapshotID string)
|
||||
if err != nil {
|
||||
if os.IsNotExist(err) {
|
||||
// Если файл не найден, возвращаем кастомную ошибку
|
||||
return nil, store.ErrNotFound
|
||||
return nil, agate.ErrNotFound
|
||||
}
|
||||
return nil, fmt.Errorf("failed to open blob file %s: %w", blobPath, err)
|
||||
}
|
||||
@@ -109,7 +110,7 @@ func (fs *fileSystemStore) GetBlobPath(ctx context.Context, snapshotID string) (
|
||||
// Проверяем существование файла
|
||||
if _, err := os.Stat(blobPath); err != nil {
|
||||
if os.IsNotExist(err) {
|
||||
return "", store.ErrNotFound
|
||||
return "", agate.ErrNotFound
|
||||
}
|
||||
return "", fmt.Errorf("failed to stat blob file %s: %w", blobPath, err)
|
||||
}
|
||||
|
||||
@@ -6,6 +6,7 @@ import (
|
||||
"encoding/json"
|
||||
"errors"
|
||||
"fmt"
|
||||
agate "gitea.unprism.ru/KRBL/Agate"
|
||||
"gitea.unprism.ru/KRBL/Agate/store"
|
||||
_ "github.com/mattn/go-sqlite3"
|
||||
"os"
|
||||
@@ -130,7 +131,7 @@ func (s *sqliteStore) GetSnapshotMetadata(ctx context.Context, snapshotID string
|
||||
if err != nil {
|
||||
if errors.Is(err, sql.ErrNoRows) {
|
||||
// Если запись не найдена, возвращаем кастомную ошибку
|
||||
return nil, store.ErrNotFound
|
||||
return nil, agate.ErrNotFound
|
||||
}
|
||||
return nil, fmt.Errorf("failed to query snapshot %s: %w", snapshotID, err)
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user